typeutil

package
Version: v0.3.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 17, 2022 License: MIT Imports: 9 Imported by: 19

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func All added in v0.3.0

func All(typ types.Type, fn func(*typeparams.Term) bool) bool

All is a wrapper for NewTypeSet(typ).All(fn).

func Any added in v0.3.0

func Any(typ types.Type, fn func(*typeparams.Term) bool) bool

Any is a wrapper for NewTypeSet(typ).Any(fn).

func Callee

func Callee(info *types.Info, call *ast.CallExpr) types.Object

func CoreType added in v0.3.0

func CoreType(typ types.Type) types.Type

CoreType is a wrapper for NewTypeSet(typ).CoreType()

func Dereference

func Dereference(T types.Type) types.Type

Dereference returns a pointer's element type; otherwise it returns T.

func DereferenceR

func DereferenceR(T types.Type) types.Type

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 FuncName

func FuncName(f *types.Func) string

func IntuitiveMethodSet

func IntuitiveMethodSet(T types.Type, msets *MethodSetCache) []*types.Selection

func IsObject

func IsObject(obj types.Object, name string) bool

func IsPointerLike

func IsPointerLike(T types.Type) bool

func IsSlice added in v0.3.0

func IsSlice(term *typeparams.Term) bool

func IsType

func IsType(T types.Type, name string) bool

OPT(dh): IsType is kind of expensive; should we really use it?

Types

type Field

type Field struct {
	Var  *types.Var
	Tag  string
	Path []int
}

func FlattenFields

func FlattenFields(T *types.Struct) []Field

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 Hasher added in v0.2.0

type Hasher = typeutil.Hasher

func MakeHasher added in v0.2.0

func MakeHasher() Hasher

type Iterator added in v0.3.0

type Iterator struct {
	// contains filtered or unexported fields
}

func NewIterator added in v0.3.0

func NewIterator(elem types.Type) *Iterator

func (*Iterator) Elem added in v0.3.0

func (t *Iterator) Elem() types.Type

func (*Iterator) String added in v0.3.0

func (t *Iterator) String() string

func (*Iterator) Underlying added in v0.3.0

func (t *Iterator) Underlying() types.Type

type Map added in v0.2.0

type Map = typeutil.Map

type MethodSetCache

type MethodSetCache = typeutil.MethodSetCache

type TypeSet added in v0.3.0

type TypeSet struct {
	Terms []*typeparams.Term
	// contains filtered or unexported fields
}

func NewTypeSet added in v0.3.0

func NewTypeSet(typ types.Type) TypeSet

func (TypeSet) All added in v0.3.0

func (ts TypeSet) All(fn func(*typeparams.Term) bool) bool

All calls fn for each term in the type set and reports whether all invocations returned true. If the type set is empty or unconstrained, All immediately returns false.

func (TypeSet) Any added in v0.3.0

func (ts TypeSet) Any(fn func(*typeparams.Term) bool) bool

Any calls fn for each term in the type set and reports whether any invocation returned true. It stops after the first call that returned true.

func (TypeSet) CoreType added in v0.3.0

func (ts TypeSet) CoreType() types.Type

CoreType returns the type set's core type, or nil if it has none. The function only looks at type terms and may thus return core types for some empty type sets, such as 'interface { map[int]string; foo() }'

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL