package typeutil
import "honnef.co/go/tools/go/types/typeutil"
Index ¶
- func All(typ types.Type, fn func(*types.Term) bool) bool
- func Any(typ types.Type, fn func(*types.Term) bool) bool
- func Callee(info *types.Info, call *ast.CallExpr) types.Object
- func CoreType(typ types.Type) types.Type
- 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 IsPointerToTypeWithName(typ types.Type, name string) bool
- func IsSlice(term *types.Term) bool
- func IsTypeName(obj *types.TypeName, name string) bool
- func IsTypeWithName(typ types.Type, name string) bool
- type DeferStack
- func NewDeferStack() *DeferStack
- func (t *DeferStack) String() string
- func (t *DeferStack) Underlying() types.Type
- type Field
- type Hasher
- type Iterator
- func NewIterator(elem types.Type) *Iterator
- func (t *Iterator) Elem() types.Type
- func (t *Iterator) String() string
- func (t *Iterator) Underlying() types.Type
- type Map
- func (m *Map[V]) At(key types.Type) (V, bool)
- func (m *Map[V]) Delete(key types.Type) bool
- func (m *Map[V]) Iterate(f func(key types.Type, value V))
- func (m *Map[V]) Keys() []types.Type
- func (m *Map[V]) KeysString() string
- func (m *Map[V]) Len() int
- func (m *Map[V]) Set(key types.Type, value V)
- func (m *Map[V]) SetHasher(h typeutil.Hasher)
- func (m *Map[V]) String() string
- type MethodSetCache
- type TypeSet
Functions ¶
func All ¶
All is a wrapper for NewTypeSet(typ).All(fn).
func Any ¶
Any is a wrapper for NewTypeSet(typ).Any(fn).
func Callee ¶
func CoreType ¶
CoreType is a wrapper for NewTypeSet(typ).CoreType()
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 FuncName ¶
func IntuitiveMethodSet ¶
func IntuitiveMethodSet(T types.Type, msets *MethodSetCache) []*types.Selection
func IsObject ¶
func IsPointerLike ¶
IsPointerLike returns true if type T is like a pointer. This returns true for all nillable types, unsafe.Pointer, and type sets where at least one term is pointer-like.
func IsPointerToTypeWithName ¶
func IsSlice ¶
func IsTypeName ¶
IsTypeName reports whether obj represents the qualified name. If obj is a type alias, IsTypeName checks both the alias and the aliased type, if the aliased type has a type name.
func IsTypeWithName ¶
IsTypeWithName reports whether typ represents a type with the qualified name, If typ is a type alias, IsTypeWithName checks both the alias and the aliased type. The following types can have names: Basic, Named, Alias.
Types ¶
type DeferStack ¶
type DeferStack struct{}
func NewDeferStack ¶
func NewDeferStack() *DeferStack
func (*DeferStack) String ¶
func (t *DeferStack) String() string
func (*DeferStack) Underlying ¶
func (t *DeferStack) Underlying() types.Type
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 Hasher ¶
func MakeHasher ¶
func MakeHasher() Hasher
type Iterator ¶
type Iterator struct {
// contains filtered or unexported fields
}
func NewIterator ¶
func (*Iterator) Elem ¶
func (*Iterator) String ¶
func (*Iterator) Underlying ¶
type Map ¶
type Map[V any] struct { // contains filtered or unexported fields }
func (*Map[V]) At ¶
func (*Map[V]) Delete ¶
func (*Map[V]) Iterate ¶
func (*Map[V]) Keys ¶
func (*Map[V]) KeysString ¶
func (*Map[V]) Len ¶
func (*Map[V]) Set ¶
func (*Map[V]) SetHasher ¶
func (*Map[V]) String ¶
type MethodSetCache ¶
type MethodSetCache = typeutil.MethodSetCache
type TypeSet ¶
func NewTypeSet ¶
func (TypeSet) All ¶
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 ¶
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 ¶
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() }'
Source Files ¶
ext.go typeparams.go upstream.go util.go
- Version
- v0.6.0
- Published
- Feb 11, 2025
- Platform
- windows/amd64
- Imports
- 10 packages
- Last checked
- 5 minutes ago –
Tools for package owners.