Documentation
¶
Index ¶
- func CallableImportPaths(ref string) []string
- func TypeExprImportPaths(input string) ([]string, error)
- type Function
- type Loader
- func (l *Loader) Function(ref string) (*Function, error)
- func (l *Loader) Method(ref string) (*Method, error)
- func (l *Loader) PackageNames() map[string]string
- func (l *Loader) Preload(importPaths []string) error
- func (l *Loader) Type(ref string) (*Type, error)
- func (l *Loader) TypeExpr(ref string, typeArgs map[string]string) (*TypeExpr, error)
- type LoaderOption
- type Method
- type Type
- type TypeExpr
- type TypeExprKind
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CallableImportPaths ¶
CallableImportPaths returns every possible package portion of a function or method reference.
func TypeExprImportPaths ¶
TypeExprImportPaths returns every possible import path referenced by a supported type expression. Resolution tries the same candidates later, after they have been loaded together.
Types ¶
type Function ¶
type Function struct {
Ref string
ImportPath string
Name string
Func *types.Func
Signature *types.Signature
}
Function is a loaded package-level Go function referenced by a Tego option.
type Loader ¶
type Loader struct {
// contains filtered or unexported fields
}
Loader is a simplified, caching Go type loader that is built to load the symbols required by Tego for things like tegopb.GoType's type ref, and to and from proto callables.
func NewLoader ¶
func NewLoader(opts ...LoaderOption) *Loader
NewLoader returns a new Loader instance.
func (*Loader) Function ¶
Function attempts to load the function with the given ref, returning a Function instance if successful.
func (*Loader) Method ¶
Method attempts to load the method with the given ref, returning a Method instance if successful.
func (*Loader) PackageNames ¶
PackageNames returns the declared package name for every package currently cached by the loader.
func (*Loader) Preload ¶
Preload loads importPaths together so that all of their dependencies share one go/types universe. Packages with loading errors are left out of the cache so that resolving one of their symbols later still returns the usual focused error.
type LoaderOption ¶
type LoaderOption func(*Loader)
LoaderOption allows this Loader to be customized during construction.
func WithDir ¶
func WithDir(dir string) LoaderOption
WithDir sets the directory packages are loaded from.
func WithPackagesConfig ¶
func WithPackagesConfig(config *packages.Config) LoaderOption
WithPackagesConfig allows custom packages.Config to be specified.
type Method ¶
type Method struct {
Ref string
ImportPath string
Receiver string
Name string
Func *types.Func
Signature *types.Signature
}
Method is a loaded Go method referenced by a Tego option.
type Type ¶
type Type struct {
Ref string
ImportPath string
Name string
TypeName *types.TypeName
Type types.Type
Named *types.Named
}
Type is a loaded named Go type referenced by a Tego option.
type TypeExpr ¶
type TypeExpr struct {
Ref string
Kind TypeExprKind
ImportPath string
Name string
TypeName *types.TypeName
Type types.Type
Named *types.Named
Args []TypeExpr
Elem *TypeExpr
Key *TypeExpr
Value *TypeExpr
Length int64
}
TypeExpr is a parsed and loaded Go type expression used by custom go_type options.
type TypeExprKind ¶
type TypeExprKind uint
TypeExprKind enumerates the possible outer forms of a parsed Go type expression.
const ( // TypeExprKindNamed is a named Go type, possibly with type arguments. TypeExprKindNamed TypeExprKind = iota // TypeExprKindPointer is a pointer type expression. TypeExprKindPointer // TypeExprKindSlice is a slice type expression. TypeExprKindSlice // TypeExprKindPredeclared is a predeclared Go value type. TypeExprKindPredeclared // TypeExprKindArray is a fixed-length array type expression. TypeExprKindArray // TypeExprKindMap is a map type expression. TypeExprKindMap )