Documentation ¶
Index ¶
- func ExprString(expr ast.Expr) string
- func FixImport(src []byte, file string)
- func GetImportPath(file string) string
- func GetMod() string
- func RewriteJsonTag(file string, omitempty bool, convert func(old string) string) (string, error)
- func Visit(files *[]string) filepath.WalkFunc
- type FieldMeta
- type InterfaceCollector
- type InterfaceMeta
- type MethodMeta
- type PackageMeta
- type StructCollector
- type StructMeta
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExprString ¶ added in v0.2.6
func GetImportPath ¶
func RewriteJsonTag ¶ added in v0.2.6
Example ¶
file := pathutils.Abs("testfiles/rewritejsontag.go") result, err := RewriteJsonTag(file, true, strcase.ToLowerCamel) if err != nil { panic(err) } fmt.Println(result)
Output: package main type base struct { Index string `json:"index,omitempty"` Type string `json:"type,omitempty"` } type struct1 struct { base Name string `json:"name,omitempty"` StructType int `json:"structType,omitempty" dd:"awesomtag"` Format string `dd:"anothertag" json:"format,omitempty"` Pos int `json:"pos,omitempty"` }
Types ¶
type InterfaceCollector ¶ added in v0.1.4
type InterfaceCollector struct { Interfaces []InterfaceMeta Package PackageMeta // contains filtered or unexported fields }
func BuildInterfaceCollector ¶ added in v0.2.6
func BuildInterfaceCollector(file string, exprString func(ast.Expr) string) InterfaceCollector
func NewInterfaceCollector ¶ added in v0.2.6
func NewInterfaceCollector(exprString func(ast.Expr) string) *InterfaceCollector
type InterfaceMeta ¶ added in v0.1.4
type InterfaceMeta struct { Name string Methods []MethodMeta Comments []string }
type MethodMeta ¶ added in v0.1.4
type MethodMeta struct { Recv string Name string Params []FieldMeta Results []FieldMeta Comments []string }
func GetMethodMeta ¶ added in v0.2.6
func GetMethodMeta(spec *ast.FuncDecl) MethodMeta
func NewMethodMeta ¶ added in v0.2.6
func (MethodMeta) String ¶ added in v0.2.6
func (mm MethodMeta) String() string
type PackageMeta ¶
type PackageMeta struct {
Name string
}
type StructCollector ¶
type StructCollector struct { Structs []StructMeta Methods map[string][]MethodMeta Package PackageMeta NonStructTypeMap map[string]ast.Expr // contains filtered or unexported fields }
func BuildStructCollector ¶ added in v0.2.6
func BuildStructCollector(file string, exprString func(ast.Expr) string) StructCollector
func NewStructCollector ¶ added in v0.2.1
func NewStructCollector(exprString func(ast.Expr) string) *StructCollector
func (*StructCollector) DocFlatEmbed ¶ added in v0.2.6
func (sc *StructCollector) DocFlatEmbed() []StructMeta
type StructMeta ¶
type StructMeta struct { Name string Fields []FieldMeta Comments []string Methods []MethodMeta IsExport bool }
func NewStructMeta ¶ added in v0.2.6
func NewStructMeta(structType *ast.StructType, exprString func(ast.Expr) string) StructMeta
Click to show internal directories.
Click to hide internal directories.