Documentation ¶
Index ¶
- Constants
- func HasGoFile(root string) (has bool, err error)
- func ModuleSrcPath(inputPath string) (goModDirPath string, err error)
- func PkgNameOrAlias(tracker ImportTracker, pkgPath string) string
- func ScanCurrentMod() *scanner
- func ScanFor(rootPath string) *scanner
- type Decl
- type DefaultImportTracker
- type Group
- type ImportTracker
- type Meta
- type Parser
- func (p *Parser) FilterByMeta(metaName string, objects []types.Object) []types.Object
- func (p *Parser) FilterByMethodHasMeta(metaName string, objects []types.Object) []types.Object
- func (p *Parser) HasMeta(metaName string, object types.Object) bool
- func (p *Parser) HasMethodHasMeta(metaName string, object types.Object) bool
- func (p *Parser) ObjectMeta(object types.Object, metaName string) (m *Meta)
- func (p *Parser) ObjectMetaGroup(object types.Object, metaName string) (parsedMetaGroup Group)
- func (p *Parser) ObjectMetaGroups(object types.Object, metaNames ...string) (parsedMetaGroups map[string]Group)
- type PathMatcher
- type PkgGen
- type PkgGenFactory
- type PkgParser
- func (pp *PkgParser) AnonymousAssign(t types.Type) (values []types.Type)
- func (pp *PkgParser) AnonymousAssignTo(v types.Type) (types []types.Type)
- func (pp *PkgParser) AssignableTo(v, t types.Type) bool
- func (pp *PkgParser) AssignableToCtx(v types.Type) bool
- func (pp *PkgParser) Comments(pos token.Pos) []string
- func (pp *PkgParser) FirstParam(methodOrFunc types.Object) types.Object
- func (pp *PkgParser) FirstResult(methodOrFunc types.Object) types.Object
- func (pp *PkgParser) Functions(pkgPath string) []types.Object
- func (pp *PkgParser) HasErrorResult(methodOrFunc types.Object) bool
- func (pp *PkgParser) Indirect(typ types.Type) types.Type
- func (pp *PkgParser) InterfaceMethods(object types.Object) []types.Object
- func (pp *PkgParser) Interfaces(pkgPath string) []types.Object
- func (pp *PkgParser) LastResult(methodOrFunc types.Object) types.Object
- func (pp *PkgParser) Load(paths ...string) (err error)
- func (pp *PkgParser) Methods(object types.Object) []types.Object
- func (pp *PkgParser) Object(pkgPath, typeName string) types.Object
- func (pp *PkgParser) ObjectComments(object types.Object) []string
- func (pp *PkgParser) ObjectPlace(object types.Object) (objectPlace Place)
- func (pp *PkgParser) Package(pkgPath string) *packages.Package
- func (pp *PkgParser) Params(methodOrFunc types.Object) []types.Object
- func (pp *PkgParser) Path(pkgPath string) string
- func (pp *PkgParser) PkgPath(path string) string
- func (pp *PkgParser) Results(methodOrFunc types.Object) []types.Object
- func (pp *PkgParser) StructMethods(object types.Object) []types.Object
- func (pp *PkgParser) Structs(pkgPath string) []types.Object
- func (pp *PkgParser) TypeName(typ types.Type) string
- func (pp *PkgParser) UnderlyingType(typ types.Type) types.Type
- type Place
- type TPGFuncMapFactory
- type TPGOption
- func WithFuncMap(funcMap template.FuncMap) TPGOption
- func WithFuncMapFactory(factory TPGFuncMapFactory) TPGOption
- func WithImportTracker(tracker ImportTracker) TPGOption
- func WithMetaParser(metaParser *Parser) TPGOption
- func WithOutputFilePrefix(prefix string) TPGOption
- func WithOutputFileSuffix(suffix string) TPGOption
- func WithOutputFilename(filename string) TPGOption
- func WithOutputFullFilename(fullFilename string) TPGOption
- func WithPkgParser(pkgParser *PkgParser) TPGOption
- type TmplPkgGen
- func (gen *TmplPkgGen) Bytes() ([]byte, error)
- func (gen *TmplPkgGen) Generate() error
- func (gen *TmplPkgGen) ImportTracker() ImportTracker
- func (gen *TmplPkgGen) MetaParser() *Parser
- func (gen *TmplPkgGen) PkgFunctions() *functions
- func (gen *TmplPkgGen) PkgParser() *PkgParser
- func (gen *TmplPkgGen) PkgPath() string
- func (gen *TmplPkgGen) Print() error
- func (gen *TmplPkgGen) Write(writer io.Writer) error
- type TmplPkgGenFactory
Constants ¶
View Source
const ( GeneratedBuildTag = "ignore_meta_generated" GeneratedComment = "// Code generated by meta. DO NOT EDIT.\n\n" )
View Source
const ( DefaultOutputFilePrefix = "zz_" DefaultOutputFileSuffix = "_gen" )
View Source
const ( TypeNamePointer = "Pointer" TypeNameStruct = "Struct" TypeNameInterface = "Interface" TypeNameSignature = "Signature" TypeNameBasic = "Basic" TypeNameSlice = "Slice" TypeNameMap = "Map" TypeNameNamed = "Named" TypeNameTuple = "Tuple" //see types.Tuple TypeNameArray = "Array" TypeNameChan = "Chan" )
Variables ¶
This section is empty.
Functions ¶
func ModuleSrcPath ¶
func PkgNameOrAlias ¶
func PkgNameOrAlias(tracker ImportTracker, pkgPath string) string
func ScanCurrentMod ¶
func ScanCurrentMod() *scanner
Types ¶
type DefaultImportTracker ¶
type DefaultImportTracker struct {
// contains filtered or unexported fields
}
func NewDefaultImportTracker ¶
func NewDefaultImportTracker(localPkgPath string) *DefaultImportTracker
func (*DefaultImportTracker) Import ¶
func (tracker *DefaultImportTracker) Import(pkgPath string) string
func (*DefaultImportTracker) ImportLines ¶
func (tracker *DefaultImportTracker) ImportLines() []string
func (*DefaultImportTracker) LocalNameOf ¶
func (tracker *DefaultImportTracker) LocalNameOf(pkgPath string) string
type ImportTracker ¶
type Meta ¶
type Meta struct {
// contains filtered or unexported fields
}
func (*Meta) Properties ¶
func (*Meta) QualifyName ¶
func (*Meta) SetProperty ¶
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
func (*Parser) FilterByMeta ¶
func (*Parser) FilterByMethodHasMeta ¶
func (*Parser) HasMethodHasMeta ¶
func (*Parser) ObjectMeta ¶
func (*Parser) ObjectMetaGroup ¶
type PathMatcher ¶
var RegexOrPathMatcher PathMatcher = func(absPath, relPath string, patterns ...string) (match bool, err error) { if len(patterns) == 0 || (len(patterns) == 1 && len(patterns[0]) == 0) { match = true return } for _, pattern := range patterns { match, err = regexp.MatchString(pattern, relPath) if err != nil { return } if match { return } } return }
type PkgGenFactory ¶
type PkgParser ¶
type PkgParser struct {
// contains filtered or unexported fields
}
func NewPkgParser ¶
func NewPkgParser() *PkgParser
func (*PkgParser) AnonymousAssign ¶
AnonymousAssign return anonymous assign some value to t var _ Foo = FooImpl{} Foo is the t,FooImpl is the result
func (*PkgParser) AnonymousAssignTo ¶
AnonymousAssignTo return anonymous assign some value to t var _ Foo = FooImpl{} Foo is the result,FooImpl is the v
func (*PkgParser) AssignableTo ¶
AssignableTo reports whether a value of type V is assignable to a variable of type T. The behavior of AssignableTo is undefined if V or T is an uninstantiated generic type.
func (*PkgParser) AssignableToCtx ¶
AssignableToCtx reports whether a value of type V is assignable to context.Context. The behavior of AssignableTo is undefined if V or T is an uninstantiated generic type.
func (*PkgParser) FirstParam ¶
func (*PkgParser) FirstResult ¶
func (*PkgParser) HasErrorResult ¶
func (*PkgParser) InterfaceMethods ¶
func (*PkgParser) LastResult ¶
func (*PkgParser) ObjectComments ¶
func (*PkgParser) ObjectPlace ¶
func (*PkgParser) StructMethods ¶
type TPGFuncMapFactory ¶
type TPGFuncMapFactory func(generator *TmplPkgGen) template.FuncMap
type TPGOption ¶
type TPGOption func(gen *TmplPkgGen)
func WithFuncMap ¶
func WithFuncMapFactory ¶
func WithFuncMapFactory(factory TPGFuncMapFactory) TPGOption
func WithImportTracker ¶
func WithImportTracker(tracker ImportTracker) TPGOption
func WithMetaParser ¶
func WithOutputFilePrefix ¶
func WithOutputFileSuffix ¶
func WithOutputFilename ¶
func WithOutputFullFilename ¶
func WithPkgParser ¶
type TmplPkgGen ¶
type TmplPkgGen struct {
// contains filtered or unexported fields
}
func NewTmplPkgGen ¶
func NewTmplPkgGen(path string, templateText string, options ...TPGOption) (gen *TmplPkgGen, err error)
func (*TmplPkgGen) Bytes ¶
func (gen *TmplPkgGen) Bytes() ([]byte, error)
func (*TmplPkgGen) Generate ¶
func (gen *TmplPkgGen) Generate() error
func (*TmplPkgGen) ImportTracker ¶
func (gen *TmplPkgGen) ImportTracker() ImportTracker
func (*TmplPkgGen) MetaParser ¶
func (gen *TmplPkgGen) MetaParser() *Parser
func (*TmplPkgGen) PkgFunctions ¶
func (gen *TmplPkgGen) PkgFunctions() *functions
func (*TmplPkgGen) PkgParser ¶
func (gen *TmplPkgGen) PkgParser() *PkgParser
func (*TmplPkgGen) PkgPath ¶
func (gen *TmplPkgGen) PkgPath() string
func (*TmplPkgGen) Print ¶
func (gen *TmplPkgGen) Print() error
type TmplPkgGenFactory ¶
type TmplPkgGenFactory struct {
// contains filtered or unexported fields
}
func NewTmplPkgGenFactory ¶
func NewTmplPkgGenFactory(templateText string, options ...TPGOption) *TmplPkgGenFactory
Source Files ¶
Click to show internal directories.
Click to hide internal directories.