Documentation ¶
Index ¶
- func ArgsFromFields(file *types.GoFile, fields *ast.FieldList) types.Args
- func DepPackagePathFromModule(moduleName, modulePath, pkg string) string
- func DependenciesFromGoMod(data string) ([]types.Dependency, error)
- func DependencyForPackage(pkg string, deps []types.Dependency) *types.Dependency
- func GoFile(path string) (*types.GoFile, error)
- func GoMod(path string) ([]byte, error)
- func GoSourceFilesFromPackage(pkgPath string) ([]string, error)
- func ImportStringForPackage(file *types.GoFile, pkg string) string
- func InterfaceFromTypeSpec(file *types.GoFile, typeSpec *ast.TypeSpec) *types.Interface
- func InterfacesFromASTFile(file *types.GoFile) []types.Interface
- func ModuleNameFromGoMod(path string) (string, error)
- func ParseFile(ctx *Context, path string, query string, depth int) ([]*types.Interface, []*types.Struct, error)
- func Path4Package(moduleName, modulePath, pkgImportPath, fileOrPackage string) (string, error)
- func SearchFile(file string) (string, error)
- func SearchFileUp(file, dir string, heightLimit int) (string, error)
- func SearchGoModUp(dir string, heightLimit int) (string, error)
- func StructFromTypeSpec(file *types.GoFile, typeSpec *ast.TypeSpec) *types.Struct
- func TypeDefs(ctx *Context, file *types.GoFile, name string, depth int) ([]*types.Interface, []*types.Struct, error)
- func TypeFromArrayType(file *types.GoFile, at *ast.ArrayType) types.Type
- func TypeFromEllipsis(file *types.GoFile, el *ast.Ellipsis) types.Type
- func TypeFromExpr(file *types.GoFile, field ast.Expr) types.Type
- func TypeFromIdent(file *types.GoFile, id *ast.Ident) types.Type
- func TypeFromMapType(file *types.GoFile, mt *ast.MapType) types.Type
- func TypeFromPackage(ctx *Context, file *types.GoFile, pkgName string, name string, depth int) ([]*types.Interface, []*types.Struct, error)
- func TypeFromSelectorExpr(file *types.GoFile, se *ast.SelectorExpr) types.Type
- func TypeFromStarExpr(file *types.GoFile, se *ast.StarExpr) types.Type
- func TypeIndex(pkgImportStr, typeName string) string
- func TypesFromASTFile(file *types.GoFile) ([]*types.Interface, []*types.Struct)
- func TypesRecursive(ctx *Context, file *types.GoFile, ifaces []*types.Interface, ...) ([]*types.Interface, []*types.Struct, error)
- type Context
- type Interfaces
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ArgsFromFields ¶
ArgsFromFields extract types.Args from *ast.FieldList
func DepPackagePathFromModule ¶
DepPackagePathFromModule returns fs path for pkg, given moduleName and modulePath
func DependenciesFromGoMod ¶
func DependenciesFromGoMod(data string) ([]types.Dependency, error)
func DependencyForPackage ¶
func DependencyForPackage(pkg string, deps []types.Dependency) *types.Dependency
DependencyForPackage return corresponding *types.Dependency for pkg
func GoSourceFilesFromPackage ¶
GoSourceFilesFromPackage returns list of *.go src files in pkgPath package except doc.go, *_test.go
func ImportStringForPackage ¶ added in v0.1.0
func InterfaceFromTypeSpec ¶
InterfaceFromTypeSpec extract interface from *ast.TypeSpec
func InterfacesFromASTFile ¶
InterfacesFromASTFile extract from *ast.File
func ModuleNameFromGoMod ¶
ModuleNameFromGoMod read go.mod from path, returns module name or error
func ParseFile ¶ added in v0.1.0
func ParseFile(ctx *Context, path string, query string, depth int) ([]*types.Interface, []*types.Struct, error)
ParseFile exported func TODO: edit
func Path4Package ¶ added in v0.1.0
Path4Package returns pkg source dir path;
func SearchFile ¶ added in v0.1.0
SearchFile looks for file in current directory
func SearchFileUp ¶
SearchFileUp looks for file in heightLimit directories up
func SearchGoModUp ¶
SearchGoModUp is SearchFileUp for go.mod
func StructFromTypeSpec ¶
StructFromTypeSpec extract *types.Struct from *ast.TypeSpec
func TypeDefs ¶ added in v0.1.0
func TypeDefs(ctx *Context, file *types.GoFile, name string, depth int) ([]*types.Interface, []*types.Struct, error)
TypeDefs exported func TODO: edit
func TypeFromPackage ¶ added in v0.1.0
func TypeFromPackage(ctx *Context, file *types.GoFile, pkgName string, name string, depth int) ([]*types.Interface, []*types.Struct, error)
TypeFromPackage 1. get package import path. 2. Get source files in this package. 3. Look for name definition in package files
func TypeFromSelectorExpr ¶
func TypesFromASTFile ¶
TypesFromASTFile exported func TODO: edit
func TypesRecursive ¶ added in v0.1.0
func TypesRecursive(ctx *Context, file *types.GoFile, ifaces []*types.Interface, structs []*types.Struct, depth int) ([]*types.Interface, []*types.Struct, error)
TypesRecursive looks for non-builtin types in ifaces & structs. Try to find in sources. Return found.
Types ¶
type Context ¶ added in v0.1.0
type Context struct { Interface map[string]*types.Interface Struct map[string]*types.Struct File map[string]*types.GoFile Type map[string]types.Type }
func NewContext ¶ added in v0.1.0
func NewContext() *Context