Documentation ¶
Index ¶
- func Callee(info *types.Info, call *ast.CallExpr) types.Object
- func Dependencies(pkgs ...*types.Package) []*types.Package
- func Dereference(T types.Type) types.Type
- func DereferenceR(T types.Type) types.Type
- func FuncName(f *types.Func) string
- func IntuitiveMethodSet(T types.Type, msets *MethodSetCache) []*types.Selection
- func IsObject(obj types.Object, name string) bool
- func IsPointerLike(T types.Type) bool
- func IsType(T types.Type, name string) bool
- func StaticCallee(info *types.Info, call *ast.CallExpr) *types.Func
- type Field
- type MethodSetCache
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Callee ¶
Callee returns the named target of a function call, if any: a function, method, builtin, or variable.
func Dependencies ¶
Dependencies returns all dependencies of the specified packages.
Dependent packages appear in topological order: if package P imports package Q, Q appears earlier than P in the result. The algorithm follows import statements in the order they appear in the source code, so the result is a total order.
func Dereference ¶
Dereference returns a pointer's element type; otherwise it returns T.
func DereferenceR ¶
DereferenceR returns a pointer's element type; otherwise it returns T. If the element type is itself a pointer, DereferenceR will be applied recursively.
func IntuitiveMethodSet ¶
func IntuitiveMethodSet(T types.Type, msets *MethodSetCache) []*types.Selection
IntuitiveMethodSet returns the intuitive method set of a type T, which is the set of methods you can call on an addressable value of that type.
The result always contains MethodSet(T), and is exactly MethodSet(T) for interface types and for pointer-to-concrete types. For all other concrete types T, the result additionally contains each method belonging to *T if there is no identically named method on T itself.
This corresponds to user intuition about method sets; this function is intended only for user interfaces.
The order of the result is as for types.MethodSet(T).
func IsPointerLike ¶
Types ¶
type Field ¶
func FlattenFields ¶
FlattenFields recursively flattens T and embedded structs, returning a list of fields. If multiple fields with the same name exist, all will be returned.
type MethodSetCache ¶
type MethodSetCache struct {
// contains filtered or unexported fields
}
A MethodSetCache records the method set of each type T for which MethodSet(T) is called so that repeat queries are fast. The zero value is a ready-to-use cache instance.
func (*MethodSetCache) MethodSet ¶
func (cache *MethodSetCache) MethodSet(T types.Type) *types.MethodSet
MethodSet returns the method set of type T. It is thread-safe.
If cache is nil, this function is equivalent to types.NewMethodSet(T). Utility functions can thus expose an optional *MethodSetCache parameter to clients that care about performance.