Documentation
¶
Index ¶
- func LcFirst(str string) string
- func UcFirst(str string) string
- type DeclResult
- type ExprResult
- type Field
- type FieldResult
- type FileResult
- type Func
- type IIIIIIIInfo
- type IInspector
- type IInspectorMock
- type IInterface
- type IInterfaceMock
- type IPackage
- type IPackageMock
- type IPackages
- type IPackagesMock
- type IParser
- type IParserMock
- type IPkgInfo
- type IPkgInfoMock
- type IStruct
- type IStructMock
- type ImportPathAlias
- type InspectOption
- type Inspector
- type InspectorMock
- type InspectorMockMock
- type Interface
- type InterfaceMock
- type InterfaceMockMock
- type Ivisitor
- type IvisitorMock
- type Method
- type Op
- type Option
- type Package
- type PackageMock
- type PackageMockMock
- type Packages
- type PackagesMock
- type PackagesMockMock
- type Parser
- type ParserMock
- type ParserMockMock
- type PkgInfo
- type PkgInfoMock
- type PkgInfoMockMock
- type SpecResult
- type StmtResult
- type Struct
- type StructMock
- func (mockRecv *StructMock) Demo(in types.Array) types.Basic
- func (mockRecv *StructMock) MakeInterface() string
- func (mockRecv *StructMock) PointerMethod(in types.Basic) types.Slice
- func (mockRecv *StructMock) String(f Field, ip importpath.ImportPath)
- func (mockRecv *StructMock) TypeAlias(p Field, ip importpath.ImportPath)
- type StructMockMock
- func (mockRecv *StructMockMock) Demo(in types.Array) types.Basic
- func (mockRecv *StructMockMock) MakeInterface() string
- func (mockRecv *StructMockMock) PointerMethod(in types.Basic) types.Slice
- func (mockRecv *StructMockMock) String(f Field, ip importpath.ImportPath)
- func (mockRecv *StructMockMock) TypeAlias(p Field, ip importpath.ImportPath)
- type TokenResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type DeclResult ¶ added in v0.5.0
type DeclResult struct {
// contains filtered or unexported fields
}
func MakeDeclResult ¶ added in v0.5.0
func MakeDeclResult() DeclResult
type ExprResult ¶ added in v0.5.0
type ExprResult struct { Fields []Field // contains filtered or unexported fields }
func MakeExprResult ¶ added in v0.5.0
func MakeExprResult() ExprResult
func (ExprResult) Merge ¶ added in v0.6.0
func (er ExprResult) Merge(oer ExprResult) (ner ExprResult)
type Field ¶
type Field struct { Id string // 唯一标志 Name string // 名称 Anonymous bool // 是否匿名 TypesType types.Type // 原始类型 Type string // 类型,包含包导入路径 Tag string `json:"tag"` // 结构体字段的tag TagBasicLit *ast.BasicLit // ast的tag类型 Doc string // 文档 Comment string // 注释 }
Field 字段
type FieldResult ¶ added in v0.5.0
func MakeFieldResult ¶ added in v0.5.0
func MakeFieldResult() FieldResult
type FileResult ¶ added in v0.5.0
type FileResult struct {
// contains filtered or unexported fields
}
func MakeFileResult ¶ added in v0.5.0
func MakeFileResult() FileResult
type Func ¶ added in v0.6.0
type Func struct { Origin *types.Func PkgPath string // 包路径 Recv string // 方法的receiver Name string Signature string Calls []Func // 调用的函数/方法 }
func (Func) PrintCallGraph ¶ added in v0.6.0
PrintCallGraph 打印调用图,用ignore忽略包,用depth指定深度
type IInspector ¶ added in v0.5.0
type IInspectorMock ¶ added in v0.5.0
type IInterface ¶ added in v0.5.0
type IInterface interface{ MakeMock() string }
type IInterfaceMock ¶ added in v0.5.0
type IInterfaceMock interface{ MakeMock() string }
type IPackageMock ¶ added in v0.5.0
type IPackagesMock ¶ added in v0.5.0
type IParserMock ¶ added in v0.5.0
type IPkgInfoMock ¶ added in v0.5.0
type IStruct ¶
type IStruct interface { Demo(in types.Array) types.Basic MakeInterface() string PointerMethod(in types.Basic) types.Slice String(f Field, ip importpath.ImportPath) TypeAlias(p Field, ip importpath.ImportPath) }
type IStructMock ¶ added in v0.5.0
type IStructMock interface { Demo(in types.Array) types.Basic MakeInterface() string PointerMethod(in types.Basic) types.Slice String(f Field, ip importpath.ImportPath) TypeAlias(p Field, ip importpath.ImportPath) }
type ImportPathAlias ¶
type ImportPathAlias = importpath.ImportPath
type InspectOption ¶ added in v0.5.0
type InspectOption struct {
Parser *Parser
}
type Inspector ¶ added in v0.5.0
type Inspector struct {
// contains filtered or unexported fields
}
func NewInspector ¶ added in v0.5.0
func NewInspector(opt InspectOption) *Inspector
func (*Inspector) InspectFile ¶ added in v0.5.0
func (ins *Inspector) InspectFile(file *ast.File) (result FileResult)
type InspectorMock ¶ added in v0.5.0
type InspectorMock struct { InspectFileFunc func(file *ast.File) (result FileResult) InspectPkgFunc func(pkg *packages.Package) Package }
func (*InspectorMock) InspectFile ¶ added in v0.5.0
func (mockRecv *InspectorMock) InspectFile(file *ast.File) (result FileResult)
func (*InspectorMock) InspectPkg ¶ added in v0.5.0
func (mockRecv *InspectorMock) InspectPkg(pkg *packages.Package) Package
type InspectorMockMock ¶ added in v0.5.0
type InspectorMockMock struct { InspectFileFunc func(file *ast.File) (result FileResult) InspectPkgFunc func(pkg *packages.Package) Package }
func (*InspectorMockMock) InspectFile ¶ added in v0.5.0
func (mockRecv *InspectorMockMock) InspectFile(file *ast.File) (result FileResult)
func (*InspectorMockMock) InspectPkg ¶ added in v0.5.0
func (mockRecv *InspectorMockMock) InspectPkg(pkg *packages.Package) Package
type Interface ¶ added in v0.5.0
type Interface struct { *types.Interface PkgPath string PkgName string Name string TypeParams *ast.FieldList Methods []Method // 方法列表 }
func (Interface) RemoveFirst ¶ added in v0.31.1
type InterfaceMock ¶ added in v0.5.0
type InterfaceMock struct {
MakeMockFunc func() string
}
func (*InterfaceMock) MakeMock ¶ added in v0.5.0
func (mockRecv *InterfaceMock) MakeMock() string
type InterfaceMockMock ¶ added in v0.5.0
type InterfaceMockMock struct {
MakeMockFunc func() string
}
func (*InterfaceMockMock) MakeMock ¶ added in v0.5.0
func (mockRecv *InterfaceMockMock) MakeMock() string
type IvisitorMock ¶ added in v0.5.0
type Op ¶ added in v0.6.0
type Op string
const ( OpReplace Op = "replace" OpMock Op = "mock" OpImpl Op = "impl" OpInterface Op = "interface" OpCallgraph Op = "callgraph" OpGenProject Op = "genproject" OpGenProxy Op = "genproxy" OpFind Op = "find" OpGenStructFromSQL Op = "sql2struct" OpGenDataForTable Op = "gendata" OpGenStructFromJSON Op = "json2struct" OpProxy Op = "proxy" )
type Option ¶
type Option struct { Op Op // 操作,如生成接口,生成实现等 Filter func(os.FileInfo) bool // 过滤器 UseSourceImporter bool // 使用源码importer ReplaceImportPath bool // 替换导入路径 FromPath string ToPath string Output io.Writer NeedCall bool // 需要记录调用了哪些函数/方法 ReplaceCallExpr bool // 替换调用表达式 Mode string // 模式:normal offsite }
Option 选项
type Package ¶ added in v0.5.0
func (Package) NewGoFileWithSuffix ¶ added in v0.5.0
func (Package) SaveInterface ¶ added in v0.5.0
type PackageMock ¶ added in v0.5.0
type PackageMock struct { NewGoFileWithSuffixFunc func(suffix string) (file string) SaveInterfaceFunc func(file string) error SaveMockFunc func(file string) error }
func (*PackageMock) NewGoFileWithSuffix ¶ added in v0.5.0
func (mockRecv *PackageMock) NewGoFileWithSuffix(suffix string) (file string)
func (*PackageMock) SaveInterface ¶ added in v0.5.0
func (mockRecv *PackageMock) SaveInterface(file string) error
func (*PackageMock) SaveMock ¶ added in v0.5.0
func (mockRecv *PackageMock) SaveMock(file string) error
type PackageMockMock ¶ added in v0.5.0
type PackageMockMock struct { NewGoFileWithSuffixFunc func(suffix string) (file string) SaveInterfaceFunc func(file string) error SaveMockFunc func(file string) error }
func (*PackageMockMock) NewGoFileWithSuffix ¶ added in v0.5.0
func (mockRecv *PackageMockMock) NewGoFileWithSuffix(suffix string) (file string)
func (*PackageMockMock) SaveInterface ¶ added in v0.5.0
func (mockRecv *PackageMockMock) SaveInterface(file string) error
func (*PackageMockMock) SaveMock ¶ added in v0.5.0
func (mockRecv *PackageMockMock) SaveMock(file string) error
type PackagesMock ¶ added in v0.5.0
type PackagesMockMock ¶ added in v0.5.0
type Parser ¶
type Parser struct { PkgInfo // contains filtered or unexported fields }
Parser 解析器 解析指定的包导入路径,获取go源码信息
func (*Parser) GetPkgInfo ¶
func (*Parser) GetStandardPackages ¶ added in v0.6.0
type ParserMock ¶ added in v0.5.0
type ParserMock struct { GetPkgInfoFunc func() PkgInfo ParseASTFunc func(importPath string) (structs []Struct, err error) ParseByGoPackagesFunc func(patterns ...string) (result Packages, err error) }
func (*ParserMock) GetPkgInfo ¶ added in v0.5.0
func (mockRecv *ParserMock) GetPkgInfo() PkgInfo
func (*ParserMock) ParseAST ¶ added in v0.5.0
func (mockRecv *ParserMock) ParseAST(importPath string) (structs []Struct, err error)
func (*ParserMock) ParseByGoPackages ¶ added in v0.5.0
func (mockRecv *ParserMock) ParseByGoPackages(patterns ...string) (result Packages, err error)
type ParserMockMock ¶ added in v0.5.0
type ParserMockMock struct { GetPkgInfoFunc func() PkgInfo ParseASTFunc func(importPath string) (structs []Struct, err error) ParseByGoPackagesFunc func(patterns ...string) (result Packages, err error) }
func (*ParserMockMock) GetPkgInfo ¶ added in v0.5.0
func (mockRecv *ParserMockMock) GetPkgInfo() PkgInfo
func (*ParserMockMock) ParseAST ¶ added in v0.5.0
func (mockRecv *ParserMockMock) ParseAST(importPath string) (structs []Struct, err error)
func (*ParserMockMock) ParseByGoPackages ¶ added in v0.5.0
func (mockRecv *ParserMockMock) ParseByGoPackages(patterns ...string) (result Packages, err error)
type PkgInfo ¶
type PkgInfo struct {
// contains filtered or unexported fields
}
func (PkgInfo) GetPkgName ¶
type PkgInfoMock ¶ added in v0.5.0
func (*PkgInfoMock) GetDir ¶ added in v0.5.0
func (mockRecv *PkgInfoMock) GetDir() string
func (*PkgInfoMock) GetPkgName ¶ added in v0.5.0
func (mockRecv *PkgInfoMock) GetPkgName() string
type PkgInfoMockMock ¶ added in v0.5.0
func (*PkgInfoMockMock) GetDir ¶ added in v0.5.0
func (mockRecv *PkgInfoMockMock) GetDir() string
func (*PkgInfoMockMock) GetPkgName ¶ added in v0.5.0
func (mockRecv *PkgInfoMockMock) GetPkgName() string
type SpecResult ¶ added in v0.5.0
type SpecResult struct {
// contains filtered or unexported fields
}
func MakeSpecResult ¶ added in v0.5.0
func MakeSpecResult() SpecResult
type StmtResult ¶ added in v0.5.0
type StmtResult struct {
// contains filtered or unexported fields
}
func MakeStmtResult ¶ added in v0.5.0
func MakeStmtResult() StmtResult
func (StmtResult) Merge ¶ added in v0.6.0
func (er StmtResult) Merge(oer StmtResult) (ner StmtResult)
func (StmtResult) MergeExprResult ¶ added in v0.6.0
func (er StmtResult) MergeExprResult(oer ExprResult) (ner StmtResult)
type Struct ¶
type Struct struct { // 如:github.com/pkg/errors PkgPath string `json:"pkgPath" toml:"pkg_path"` // 包路径 // 如: errors PkgName string // 包名 Field Fields []Field // 字段列表 Methods []Method // 方法列表 }
Struct 结构体
func (*Struct) PointerMethod ¶ added in v0.5.0
func (Struct) String ¶
func (s Struct) String(f Field, ip importpath.ImportPath)
让它传入本包里的另外一个结构体 传入本项目其它包的结构体
func (Struct) TypeAlias ¶
func (s Struct) TypeAlias(p IIIIIIIInfo, ip ImportPathAlias)
type StructMock ¶ added in v0.5.0
type StructMock struct { DemoFunc func(in types.Array) types.Basic MakeInterfaceFunc func() string PointerMethodFunc func(in types.Basic) types.Slice StringFunc func(f Field, ip importpath.ImportPath) TypeAliasFunc func(p Field, ip importpath.ImportPath) }
func (*StructMock) Demo ¶ added in v0.5.0
func (mockRecv *StructMock) Demo(in types.Array) types.Basic
func (*StructMock) MakeInterface ¶ added in v0.5.0
func (mockRecv *StructMock) MakeInterface() string
func (*StructMock) PointerMethod ¶ added in v0.5.0
func (mockRecv *StructMock) PointerMethod(in types.Basic) types.Slice
func (*StructMock) String ¶ added in v0.5.0
func (mockRecv *StructMock) String(f Field, ip importpath.ImportPath)
func (*StructMock) TypeAlias ¶ added in v0.5.0
func (mockRecv *StructMock) TypeAlias(p Field, ip importpath.ImportPath)
type StructMockMock ¶ added in v0.5.0
type StructMockMock struct { DemoFunc func(in types.Array) types.Basic MakeInterfaceFunc func() string PointerMethodFunc func(in types.Basic) types.Slice StringFunc func(f Field, ip importpath.ImportPath) TypeAliasFunc func(p Field, ip importpath.ImportPath) }
func (*StructMockMock) Demo ¶ added in v0.5.0
func (mockRecv *StructMockMock) Demo(in types.Array) types.Basic
func (*StructMockMock) MakeInterface ¶ added in v0.5.0
func (mockRecv *StructMockMock) MakeInterface() string
func (*StructMockMock) PointerMethod ¶ added in v0.5.0
func (mockRecv *StructMockMock) PointerMethod(in types.Basic) types.Slice
func (*StructMockMock) String ¶ added in v0.5.0
func (mockRecv *StructMockMock) String(f Field, ip importpath.ImportPath)
func (*StructMockMock) TypeAlias ¶ added in v0.5.0
func (mockRecv *StructMockMock) TypeAlias(p Field, ip importpath.ImportPath)
type TokenResult ¶ added in v0.5.0
type TokenResult struct { }
func InspectToken ¶ added in v0.5.0
func InspectToken(tok token.Token) (result TokenResult)
Source Files
¶
Click to show internal directories.
Click to hide internal directories.