Documentation
¶
Index ¶
- func AddMissingImports(file *ast.File, imports []string)
- func AddModifiedComment(file *ast.File, comment string)
- func CombineTags(tag1, tag2 *ast.BasicLit, combiners map[string]TagCombiner) (*ast.BasicLit, error)
- func DeleteTagByKey(lit *ast.BasicLit, tagKey string) *ast.BasicLit
- func ExtractTagsByKey(tag *ast.BasicLit, valueMap ...map[string][]string) map[string][]string
- func GetEmptyFile(packageName string) (*ast.File, error)
- func GetJsonTagName(tag *ast.BasicLit) (string, error)
- func GetJsonTagValue(tag string) string
- func GetTagValue(tag string, tagKey string) string
- func IsBasicField(field *ast.Field) bool
- func PreviouslyModified(file *ast.File, searchString string) bool
- func RemoveTag(key string, lit *ast.BasicLit) *ast.BasicLit
- func ReplaceExprChild(decl *ast.Node, n ast.Expr)
- func ReplaceImports(file *ast.File, imports []string)
- func SearchNodes(decl ast.Node, foundNodes *[]*FoundNodes, parents []*ast.Node, ...)
- func SetExported(name string) string
- func SetUnexported(name string) string
- func TagsEqual(lit0, lit1 *ast.BasicLit) bool
- func ToSnakeCase(s string) string
- func UnnestStruct(structName *string, file *ast.File)
- type FoundNodes
- type TagCombiner
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddMissingImports ¶
func AddModifiedComment ¶
func CombineTags ¶
CombineTags Combines two tags. Uses the first seen tag, as combined tag, unless a TagCombiner for the tag key is present.
func ExtractTagsByKey ¶
func GetJsonTagValue ¶
func GetTagValue ¶
func IsBasicField ¶
func ReplaceImports ¶
func SearchNodes ¶
func SearchNodes(decl ast.Node, foundNodes *[]*FoundNodes, parents []*ast.Node, searchFunction func(node *ast.Node, parents []*ast.Node, completed *bool) bool, completed *bool)
SearchNodes Searches the Ast-tree. The search function decides what's a match. foundNodes holds all matches including their parents. This allows to modify a method call inside a function, then traverses upwards to modify the containing function parameters as well. Set completed to true inside the search function, if the search should be terminated.
func SetExported ¶
func SetUnexported ¶
func ToSnakeCase ¶
func UnnestStruct ¶
UnnestStruct Unnest structs that are contained inside other structs. If a name is given, only structs that are embedded in the named one are considered otherwise all structs inside the file.
Types ¶
type FoundNodes ¶
FoundNodes holds the information for each found node