Versions in this module Expand all Collapse all v1 v1.0.0 May 20, 2020 Changes in this version + const MODEL_EXTENDS + func AddFormerMixins(fileName, nameSpace, alias string) []string + func CleanImportsWriteGolangFile(fileName string, sourceCode []byte) ([]byte, error) + func FormatGolangCode(src []byte) ([]byte, error) + func GetLineFeature(code string) (feature string) + func GetNameList(ids []*ast.Ident) (names []string) + func ParseAndMixinFile(fileName string, verbose bool) error + func RegisterSubstitute(sub *ModelSummary) + func ReplaceModelFields(cp *CodeParser, node *DeclNode, summary *ModelSummary) + func RewritePackage(pkgpath, pkgname string) error + func TrimComment(c string) string + func WriteCodeFile(fileName string, sourceCode []byte) ([]byte, error) + func WriteGolangFile(fileName string, sourceCode []byte) ([]byte, error) + type CodeParser struct + DeclIndexes map[string][]int + DeclNodes []*DeclNode + func NewCodeParser() *CodeParser + func NewFileParser(filename string) (cp *CodeParser, err error) + func NewSourceParser(source []byte) (cp *CodeParser, err error) + func (cp *CodeParser) AllDeclNode(kind string) []*DeclNode + func (cp *CodeParser) GetDeclNode(kind string, offset int) *DeclNode + func (cp *CodeParser) ParseDecls(kind string, limit int) bool + type CodeSource struct + Alternates []PosAlt + Fileast *ast.File + Fileset *token.FileSet + Source []byte + func NewCodeSource() *CodeSource + func ResetImports(cs *CodeSource, imports map[string]string) (*CodeSource, error) + func WithImports(pkg string, source []byte, imports map[string]string) (*CodeSource, error) + func (cs *CodeSource) AddCode(code []byte) error + func (cs *CodeSource) AddImport(path, alias string) bool + func (cs *CodeSource) AddReplace(first, last ast.Node, code string) + func (cs *CodeSource) AddStringCode(code string) error + func (cs *CodeSource) AltSource() ([]byte, bool) + func (cs *CodeSource) CleanImports() (removes int) + func (cs *CodeSource) DelImport(path, alias string) bool + func (cs *CodeSource) GetComment(c *ast.CommentGroup, trim bool) string + func (cs *CodeSource) GetContent() ([]byte, error) + func (cs *CodeSource) GetFieldCode(node *DeclNode, i int) string + func (cs *CodeSource) GetNodeCode(node ast.Node) string + func (cs *CodeSource) GetPackage() string + func (cs *CodeSource) GetPackageOffset() int + func (cs *CodeSource) SetPackage(name string) (err error) + func (cs *CodeSource) SetSource(source []byte) (err error) + func (cs *CodeSource) WriteTo(filename string) error + type DeclNode struct + Comment *ast.CommentGroup + Fields []*FieldNode + Kinds []string + Names []string + Offset int + Token token.Token + func NewDeclNode(decl ast.Decl, offset int, position token.Pos) (n *DeclNode, err error) + func (n *DeclNode) ParseFunDecl(fun *ast.FuncDecl) (err error) + func (n *DeclNode) ParseGenDecl(gen *ast.GenDecl) (err error) + func (n *DeclNode) ParseStruct(fields []*ast.Field) (err error) + func (n DeclNode) GetKind() string + func (n DeclNode) GetName() string + type FieldNode struct + Comment *ast.CommentGroup + Names []string + func (n *FieldNode) GetTag() reflect.StructTag + type ModelSummary struct + Alias string + Features []string + FieldLines []string + Import string + IsChanged bool + Name string + Substitute string + func ReplaceSummary(summary, sub *ModelSummary) *ModelSummary + func (s *ModelSummary) GetSubstitute() string + func (s *ModelSummary) ParseFields(cp *CodeParser, node *DeclNode) int + func (s ModelSummary) GetInnerCode() string + func (s ModelSummary) GetSortedFeatures() []string + type PosAlt struct + Alternate []byte + End token.Position + Pos token.Position