package types

Import Path
	go/types (on golang.org and go.dev)

Dependency Relation
	imports 14 packages, and imported by 4 packages

Involved Source Files
	d-> api.go
	    assignments.go
	    builtins.go
	    call.go
	    check.go
	    conversions.go
	    decl.go
	    errors.go
	    eval.go
	    expr.go
	    exprstring.go
	    gccgosizes.go
	    initorder.go
	    labels.go
	    lookup.go
	    methodset.go
	    object.go
	    objset.go
	    operand.go
	    package.go
	    predicates.go
	    resolver.go
	    return.go
	    scope.go
	    selection.go
	    sizes.go
	    stmt.go
	    type.go
	    typestring.go
	    typexpr.go
	    universe.go

Exported Type Names

type Array (struct) An Array represents an array type. (*T) Elem() Type (*T) Len() int64 (*T) String() string (*T) Underlying() Type *T : Type *T : expvar.Var *T : fmt.Stringer func NewArray(elem Type, len int64) *Array
type Basic (struct) A Basic represents a basic type. (*T) Info() BasicInfo (*T) Kind() BasicKind (*T) Name() string (*T) String() string (*T) Underlying() Type *T : Type *T : expvar.Var *T : fmt.Stringer
type BasicInfo int BasicInfo is a set of flags describing properties of a basic type. func (*Basic).Info() BasicInfo const IsBoolean const IsComplex const IsConstType const IsFloat const IsInteger const IsNumeric const IsOrdered const IsString const IsUnsigned const IsUntyped
type BasicKind int BasicKind describes the kind of basic type. func (*Basic).Kind() BasicKind const Bool const Byte const Complex128 const Complex64 const Float32 const Float64 const Int const Int16 const Int32 const Int64 const Int8 const Invalid const Rune const String const Uint const Uint16 const Uint32 const Uint64 const Uint8 const Uintptr const UnsafePointer const UntypedBool const UntypedComplex const UntypedFloat const UntypedInt const UntypedNil const UntypedRune const UntypedString
type Builtin (struct) A Builtin represents a built-in function. Builtins don't have a valid type. (*T) Exported() bool (*T) Id() string (*T) Name() string (*T) Parent() *Scope (*T) Pkg() *Package (*T) Pos() token.Pos (*T) String() string (*T) Type() Type *T : Object *T : expvar.Var *T : fmt.Stringer
type Chan (struct) A Chan represents a channel type. (*T) Dir() ChanDir (*T) Elem() Type (*T) String() string (*T) Underlying() Type *T : Type *T : expvar.Var *T : fmt.Stringer func NewChan(dir ChanDir, elem Type) *Chan
type ChanDir int A ChanDir value indicates a channel direction. func (*Chan).Dir() ChanDir func NewChan(dir ChanDir, elem Type) *Chan const RecvOnly const SendOnly const SendRecv
type Checker (struct) A Checker maintains the state of the type checker. It must be created with NewChecker. Info *Info Info.Defs map[*ast.Ident]Object Info.Implicits map[ast.Node]Object Info.InitOrder []*Initializer Info.Scopes map[ast.Node]*Scope Info.Selections map[*ast.SelectorExpr]*Selection Info.Types map[ast.Expr]TypeAndValue Info.Uses map[*ast.Ident]Object (*T) Files(files []*ast.File) error (T) ObjectOf(id *ast.Ident) Object (T) TypeOf(e ast.Expr) Type func NewChecker(conf *Config, fset *token.FileSet, pkg *Package, info *Info) *Checker
type Config (struct) A Config specifies the configuration for type checking. The zero value for Config is a ready-to-use default configuration. DisableUnusedImportCheck bool Error func(err error) FakeImportC bool IgnoreFuncBodies bool Importer Importer Sizes Sizes (*T) Check(path string, fset *token.FileSet, files []*ast.File, info *Info) (*Package, error) func NewChecker(conf *Config, fset *token.FileSet, pkg *Package, info *Info) *Checker
type Const (struct) A Const represents a declared constant. (*T) Exported() bool (*T) Id() string (*T) Name() string (*T) Parent() *Scope (*T) Pkg() *Package (*T) Pos() token.Pos (*T) String() string (*T) Type() Type (*T) Val() constant.Value *T : Object *T : expvar.Var *T : fmt.Stringer func NewConst(pos token.Pos, pkg *Package, name string, typ Type, val constant.Value) *Const
type Error (struct) An Error describes a type-checking error; it implements the error interface. A "soft" error is an error that still permits a valid interpretation of a package (such as "unused variable"); "hard" errors may lead to unpredictable behavior if ignored. Fset *token.FileSet Msg string Pos token.Pos Soft bool (T) Error() string T : error
type Func (struct) A Func represents a declared function, concrete method, or abstract (interface) method. Its Type() is always a *Signature. An abstract method may belong to many interfaces due to embedding. (*T) Exported() bool (*T) FullName() string (*T) Id() string (*T) Name() string (*T) Parent() *Scope (*T) Pkg() *Package (*T) Pos() token.Pos (*T) Scope() *Scope (*T) String() string (*T) Type() Type *T : Object *T : expvar.Var *T : fmt.Stringer func MissingMethod(V Type, T *Interface, static bool) (method *Func, wrongType bool) func NewFunc(pos token.Pos, pkg *Package, name string, sig *Signature) *Func func (*Interface).ExplicitMethod(i int) *Func func (*Interface).Method(i int) *Func func (*Named).Method(i int) *Func func NewInterface(methods []*Func, embeddeds []*Named) *Interface func NewInterfaceType(methods []*Func, embeddeds []Type) *Interface func NewNamed(obj *TypeName, underlying Type, methods []*Func) *Named func (*Named).AddMethod(m *Func)
type Importer (interface) An Importer resolves import paths to Packages. CAUTION: This interface does not support the import of locally vendored packages. See https://golang.org/s/go15vendor. If possible, external implementations should implement ImporterFrom. (T) Import(path string) (*Package, error) ImporterFrom (interface) go/internal/srcimporter.(*Importer) func go/importer.Default() Importer func go/importer.For(compiler string, lookup importer.Lookup) Importer func go/importer.ForCompiler(fset *token.FileSet, compiler string, lookup importer.Lookup) Importer
type ImporterFrom (interface) An ImporterFrom resolves import paths to packages; it supports vendoring per https://golang.org/s/go15vendor. Use go/importer to obtain an ImporterFrom implementation. (T) Import(path string) (*Package, error) (T) ImportFrom(path, dir string, mode ImportMode) (*Package, error) go/internal/srcimporter.(*Importer) T : Importer
type ImportMode int ImportMode is reserved for future use. func ImporterFrom.ImportFrom(path, dir string, mode ImportMode) (*Package, error) func go/internal/srcimporter.(*Importer).ImportFrom(path, srcDir string, mode ImportMode) (*Package, error)
type Info (struct) Info holds result type information for a type-checked package. Only the information for which a map is provided is collected. If the package has type errors, the collected information may be incomplete. Defs map[*ast.Ident]Object Implicits map[ast.Node]Object InitOrder []*Initializer Scopes map[ast.Node]*Scope Selections map[*ast.SelectorExpr]*Selection Types map[ast.Expr]TypeAndValue Uses map[*ast.Ident]Object (*T) ObjectOf(id *ast.Ident) Object (*T) TypeOf(e ast.Expr) Type func CheckExpr(fset *token.FileSet, pkg *Package, pos token.Pos, expr ast.Expr, info *Info) (err error) func NewChecker(conf *Config, fset *token.FileSet, pkg *Package, info *Info) *Checker func (*Config).Check(path string, fset *token.FileSet, files []*ast.File, info *Info) (*Package, error)
type Initializer (struct) An Initializer describes a package-level variable, or a list of variables in case of a multi-valued initialization expression, and the corresponding initialization expression. Lhs []*Var Rhs ast.Expr (*T) String() string *T : expvar.Var *T : fmt.Stringer
type Interface (struct) An Interface represents an interface type. (*T) Complete() *Interface (*T) Embedded(i int) *Named (*T) EmbeddedType(i int) Type (*T) Empty() bool (*T) ExplicitMethod(i int) *Func (*T) Method(i int) *Func (*T) NumEmbeddeds() int (*T) NumExplicitMethods() int (*T) NumMethods() int (*T) String() string (*T) Underlying() Type *T : Type *T : expvar.Var *T : fmt.Stringer func NewInterface(methods []*Func, embeddeds []*Named) *Interface func NewInterfaceType(methods []*Func, embeddeds []Type) *Interface func (*Interface).Complete() *Interface func AssertableTo(V *Interface, T Type) bool func Implements(V Type, T *Interface) bool func MissingMethod(V Type, T *Interface, static bool) (method *Func, wrongType bool)
type Label (struct) A Label represents a declared label. Labels don't have a type. (*T) Exported() bool (*T) Id() string (*T) Name() string (*T) Parent() *Scope (*T) Pkg() *Package (*T) Pos() token.Pos (*T) String() string (*T) Type() Type *T : Object *T : expvar.Var *T : fmt.Stringer func NewLabel(pos token.Pos, pkg *Package, name string) *Label
type Map (struct) A Map represents a map type. (*T) Elem() Type (*T) Key() Type (*T) String() string (*T) Underlying() Type *T : Type *T : expvar.Var *T : fmt.Stringer func NewMap(key, elem Type) *Map
type MethodSet (struct) A MethodSet is an ordered set of concrete or abstract (interface) methods; a method is a MethodVal selection, and they are ordered by ascending m.Obj().Id(). The zero value for a MethodSet is a ready-to-use empty method set. (*T) At(i int) *Selection (*T) Len() int (*T) Lookup(pkg *Package, name string) *Selection (*T) String() string *T : expvar.Var *T : fmt.Stringer func NewMethodSet(T Type) *MethodSet
type Named (struct) A Named represents a named type. (*T) AddMethod(m *Func) (*T) Method(i int) *Func (*T) NumMethods() int (*T) Obj() *TypeName (*T) SetUnderlying(underlying Type) (*T) String() string (*T) Underlying() Type *T : Type *T : expvar.Var *T : fmt.Stringer func NewNamed(obj *TypeName, underlying Type, methods []*Func) *Named func (*Interface).Embedded(i int) *Named func NewInterface(methods []*Func, embeddeds []*Named) *Interface
type Nil (struct) Nil represents the predeclared value nil. (*T) Exported() bool (*T) Id() string (*T) Name() string (*T) Parent() *Scope (*T) Pkg() *Package (*T) Pos() token.Pos (*T) String() string (*T) Type() Type *T : Object *T : expvar.Var *T : fmt.Stringer
type Object (interface) An Object describes a named language entity such as a package, constant, type, variable, function (incl. methods), or label. All objects implement the Object interface. (T) Exported() bool (T) Id() string (T) Name() string (T) Parent() *Scope (T) Pkg() *Package (T) Pos() token.Pos (T) String() string (T) Type() Type *Builtin *Const *Func *Label *Nil *PkgName *TypeName *Var T : expvar.Var T : fmt.Stringer func LookupFieldOrMethod(T Type, addressable bool, pkg *Package, name string) (obj Object, index []int, indirect bool) func (*Info).ObjectOf(id *ast.Ident) Object func (*Scope).Insert(obj Object) Object func (*Scope).Lookup(name string) Object func (*Scope).LookupParent(name string, pos token.Pos) (*Scope, Object) func (*Selection).Obj() Object func ObjectString(obj Object, qf Qualifier) string func (*Scope).Insert(obj Object) Object
type Package (struct) A Package describes a Go package. (*T) Complete() bool (*T) Imports() []*Package (*T) MarkComplete() (*T) Name() string (*T) Path() string (*T) Scope() *Scope (*T) SetImports(list []*Package) (*T) SetName(name string) (*T) String() string *T : expvar.Var *T : fmt.Stringer func NewPackage(path, name string) *Package func (*Config).Check(path string, fset *token.FileSet, files []*ast.File, info *Info) (*Package, error) func Importer.Import(path string) (*Package, error) func ImporterFrom.Import(path string) (*Package, error) func ImporterFrom.ImportFrom(path, dir string, mode ImportMode) (*Package, error) func Object.Pkg() *Package func (*Package).Imports() []*Package func (*PkgName).Imported() *Package func go/internal/gcimporter.Import(fset *token.FileSet, packages map[string]*Package, path, srcDir string, lookup func(path string) (io.ReadCloser, error)) (pkg *Package, err error) func go/internal/srcimporter.(*Importer).Import(path string) (*Package, error) func go/internal/srcimporter.(*Importer).ImportFrom(path, srcDir string, mode ImportMode) (*Package, error) func CheckExpr(fset *token.FileSet, pkg *Package, pos token.Pos, expr ast.Expr, info *Info) (err error) func Eval(fset *token.FileSet, pkg *Package, pos token.Pos, expr string) (_ TypeAndValue, err error) func Id(pkg *Package, name string) string func LookupFieldOrMethod(T Type, addressable bool, pkg *Package, name string) (obj Object, index []int, indirect bool) func NewChecker(conf *Config, fset *token.FileSet, pkg *Package, info *Info) *Checker func NewConst(pos token.Pos, pkg *Package, name string, typ Type, val constant.Value) *Const func NewField(pos token.Pos, pkg *Package, name string, typ Type, embedded bool) *Var func NewFunc(pos token.Pos, pkg *Package, name string, sig *Signature) *Func func NewLabel(pos token.Pos, pkg *Package, name string) *Label func NewParam(pos token.Pos, pkg *Package, name string, typ Type) *Var func NewPkgName(pos token.Pos, pkg *Package, name string, imported *Package) *PkgName func NewPkgName(pos token.Pos, pkg *Package, name string, imported *Package) *PkgName func NewTypeName(pos token.Pos, pkg *Package, name string, typ Type) *TypeName func NewVar(pos token.Pos, pkg *Package, name string, typ Type) *Var func RelativeTo(pkg *Package) Qualifier func (*MethodSet).Lookup(pkg *Package, name string) *Selection func (*Package).SetImports(list []*Package) func go/internal/gccgoimporter.GetImporter(searchpaths []string, initmap map[*Package]gccgoimporter.InitData) gccgoimporter.Importer func go/internal/gccgoimporter.(*GccgoInstallation).GetImporter(incpaths []string, initmap map[*Package]gccgoimporter.InitData) gccgoimporter.Importer func go/internal/gcimporter.Import(fset *token.FileSet, packages map[string]*Package, path, srcDir string, lookup func(path string) (io.ReadCloser, error)) (pkg *Package, err error) func go/internal/srcimporter.New(ctxt *build.Context, fset *token.FileSet, packages map[string]*Package) *srcimporter.Importer var Unsafe *Package
type PkgName (struct) A PkgName represents an imported Go package. PkgNames don't have a type. (*T) Exported() bool (*T) Id() string (*T) Imported() *Package (*T) Name() string (*T) Parent() *Scope (*T) Pkg() *Package (*T) Pos() token.Pos (*T) String() string (*T) Type() Type *T : Object *T : expvar.Var *T : fmt.Stringer func NewPkgName(pos token.Pos, pkg *Package, name string, imported *Package) *PkgName
type Pointer (struct) A Pointer represents a pointer type. (*T) Elem() Type (*T) String() string (*T) Underlying() Type *T : Type *T : expvar.Var *T : fmt.Stringer func NewPointer(elem Type) *Pointer
type Qualifier (func) A Qualifier controls how named package-level objects are printed in calls to TypeString, ObjectString, and SelectionString. These three formatting routines call the Qualifier for each package-level object O, and if the Qualifier returns a non-empty string p, the object is printed in the form p.O. If it returns an empty string, only the object name O is printed. Using a nil Qualifier is equivalent to using (*Package).Path: the object is qualified by the import path, e.g., "encoding/json.Marshal". func RelativeTo(pkg *Package) Qualifier func ObjectString(obj Object, qf Qualifier) string func SelectionString(s *Selection, qf Qualifier) string func TypeString(typ Type, qf Qualifier) string func WriteSignature(buf *bytes.Buffer, sig *Signature, qf Qualifier) func WriteType(buf *bytes.Buffer, typ Type, qf Qualifier)
type Scope (struct) A Scope maintains a set of objects and links to its containing (parent) and contained (children) scopes. Objects may be inserted and looked up by name. The zero value for Scope is a ready-to-use empty scope. (*T) Child(i int) *Scope (*T) Contains(pos token.Pos) bool (*T) End() token.Pos (*T) Innermost(pos token.Pos) *Scope (*T) Insert(obj Object) Object (*T) Len() int (*T) Lookup(name string) Object (*T) LookupParent(name string, pos token.Pos) (*Scope, Object) (*T) Names() []string (*T) NumChildren() int (*T) Parent() *Scope (*T) Pos() token.Pos (*T) String() string (*T) WriteTo(w io.Writer, n int, recurse bool) *T : go/ast.Node *T : expvar.Var *T : fmt.Stringer func NewScope(parent *Scope, pos, end token.Pos, comment string) *Scope func (*Func).Scope() *Scope func Object.Parent() *Scope func (*Package).Scope() *Scope func (*Scope).Child(i int) *Scope func (*Scope).Innermost(pos token.Pos) *Scope func (*Scope).LookupParent(name string, pos token.Pos) (*Scope, Object) func (*Scope).Parent() *Scope func NewScope(parent *Scope, pos, end token.Pos, comment string) *Scope var Universe *Scope
type Selection (struct) A Selection describes a selector expression x.f. For the declarations: type T struct{ x int; E } type E struct{} func (e E) m() {} var p *T the following relations exist: Selector Kind Recv Obj Type Index Indirect p.x FieldVal T x int {0} true p.m MethodVal *T m func() {1, 0} true T.m MethodExpr T m func(T) {1, 0} false (*T) Index() []int (*T) Indirect() bool (*T) Kind() SelectionKind (*T) Obj() Object (*T) Recv() Type (*T) String() string (*T) Type() Type *T : expvar.Var *T : fmt.Stringer func (*MethodSet).At(i int) *Selection func (*MethodSet).Lookup(pkg *Package, name string) *Selection func SelectionString(s *Selection, qf Qualifier) string
type SelectionKind int SelectionKind describes the kind of a selector expression x.f (excluding qualified identifiers). func (*Selection).Kind() SelectionKind const FieldVal const MethodExpr const MethodVal
type Signature (struct) A Signature represents a (non-builtin) function or method type. The receiver is ignored when comparing signatures for identity. (*T) Params() *Tuple (*T) Recv() *Var (*T) Results() *Tuple (*T) String() string (*T) Underlying() Type (*T) Variadic() bool *T : Type *T : expvar.Var *T : fmt.Stringer func NewSignature(recv *Var, params, results *Tuple, variadic bool) *Signature func NewFunc(pos token.Pos, pkg *Package, name string, sig *Signature) *Func func WriteSignature(buf *bytes.Buffer, sig *Signature, qf Qualifier)
type Sizes (interface) Sizes defines the sizing functions for package unsafe. (T) Alignof(T Type) int64 (T) Offsetsof(fields []*Var) []int64 (T) Sizeof(T Type) int64 *StdSizes func SizesFor(compiler, arch string) Sizes
type Slice (struct) A Slice represents a slice type. (*T) Elem() Type (*T) String() string (*T) Underlying() Type *T : Type *T : expvar.Var *T : fmt.Stringer func NewSlice(elem Type) *Slice
type StdSizes (struct) StdSizes is a convenience type for creating commonly used Sizes. It makes the following simplifying assumptions: - The size of explicitly sized basic types (int16, etc.) is the specified size. - The size of strings and interfaces is 2*WordSize. - The size of slices is 3*WordSize. - The size of an array of n elements corresponds to the size of a struct of n consecutive fields of the array's element type. - The size of a struct is the offset of the last field plus that field's size. As with all element types, if the struct is used in an array its size must first be aligned to a multiple of the struct's alignment. - All other types have size WordSize. - Arrays and structs are aligned per spec definition; all other types are naturally aligned with a maximum alignment MaxAlign. *StdSizes implements Sizes. MaxAlign int64 WordSize int64 (*T) Alignof(T Type) int64 (*T) Offsetsof(fields []*Var) []int64 (*T) Sizeof(T Type) int64 *T : Sizes
type Struct (struct) A Struct represents a struct type. (*T) Field(i int) *Var (*T) NumFields() int (*T) String() string (*T) Tag(i int) string (*T) Underlying() Type *T : Type *T : expvar.Var *T : fmt.Stringer func NewStruct(fields []*Var, tags []string) *Struct
type Tuple (struct) A Tuple represents an ordered list of variables; a nil *Tuple is a valid (empty) tuple. Tuples are used as components of signatures and to represent the type of multiple assignments; they are not first class types of Go. (*T) At(i int) *Var (*T) Len() int (*T) String() string (*T) Underlying() Type *T : Type *T : expvar.Var *T : fmt.Stringer func NewTuple(x ...*Var) *Tuple func (*Signature).Params() *Tuple func (*Signature).Results() *Tuple func NewSignature(recv *Var, params, results *Tuple, variadic bool) *Signature
type Type (interface) A Type represents a type of Go. All types implement the Type interface. (T) String() string (T) Underlying() Type *Array *Basic *Chan *Interface *Map *Named *Pointer *Signature *Slice *Struct *Tuple T : expvar.Var T : fmt.Stringer func Default(typ Type) Type func (*Array).Elem() Type func (*Array).Underlying() Type func (*Basic).Underlying() Type func (*Chan).Elem() Type func (*Chan).Underlying() Type func (*Info).TypeOf(e ast.Expr) Type func (*Interface).EmbeddedType(i int) Type func (*Interface).Underlying() Type func (*Map).Elem() Type func (*Map).Key() Type func (*Map).Underlying() Type func (*Named).Underlying() Type func Object.Type() Type func (*Pointer).Elem() Type func (*Pointer).Underlying() Type func (*Selection).Recv() Type func (*Selection).Type() Type func (*Signature).Underlying() Type func (*Slice).Elem() Type func (*Slice).Underlying() Type func (*Struct).Underlying() Type func (*Tuple).Underlying() Type func Type.Underlying() Type func AssertableTo(V *Interface, T Type) bool func AssignableTo(V, T Type) bool func Comparable(T Type) bool func ConvertibleTo(V, T Type) bool func Default(typ Type) Type func Identical(x, y Type) bool func IdenticalIgnoreTags(x, y Type) bool func Implements(V Type, T *Interface) bool func IsInterface(typ Type) bool func LookupFieldOrMethod(T Type, addressable bool, pkg *Package, name string) (obj Object, index []int, indirect bool) func MissingMethod(V Type, T *Interface, static bool) (method *Func, wrongType bool) func NewArray(elem Type, len int64) *Array func NewChan(dir ChanDir, elem Type) *Chan func NewConst(pos token.Pos, pkg *Package, name string, typ Type, val constant.Value) *Const func NewField(pos token.Pos, pkg *Package, name string, typ Type, embedded bool) *Var func NewInterfaceType(methods []*Func, embeddeds []Type) *Interface func NewMap(key, elem Type) *Map func NewMethodSet(T Type) *MethodSet func NewNamed(obj *TypeName, underlying Type, methods []*Func) *Named func NewParam(pos token.Pos, pkg *Package, name string, typ Type) *Var func NewPointer(elem Type) *Pointer func NewSlice(elem Type) *Slice func NewTypeName(pos token.Pos, pkg *Package, name string, typ Type) *TypeName func NewVar(pos token.Pos, pkg *Package, name string, typ Type) *Var func TypeString(typ Type, qf Qualifier) string func WriteType(buf *bytes.Buffer, typ Type, qf Qualifier) func (*Named).SetUnderlying(underlying Type) func Sizes.Alignof(T Type) int64 func Sizes.Sizeof(T Type) int64 func (*StdSizes).Alignof(T Type) int64 func (*StdSizes).Sizeof(T Type) int64
type TypeAndValue (struct) TypeAndValue reports the type and value (for constants) of the corresponding expression. Type Type Value constant.Value (T) Addressable() bool (T) Assignable() bool (T) HasOk() bool (T) IsBuiltin() bool (T) IsNil() bool (T) IsType() bool (T) IsValue() bool (T) IsVoid() bool func Eval(fset *token.FileSet, pkg *Package, pos token.Pos, expr string) (_ TypeAndValue, err error)
type TypeName (struct) A TypeName represents a name for a (defined or alias) type. (*T) Exported() bool (*T) Id() string (*T) IsAlias() bool (*T) Name() string (*T) Parent() *Scope (*T) Pkg() *Package (*T) Pos() token.Pos (*T) String() string (*T) Type() Type *T : Object *T : expvar.Var *T : fmt.Stringer func NewTypeName(pos token.Pos, pkg *Package, name string, typ Type) *TypeName func (*Named).Obj() *TypeName func NewNamed(obj *TypeName, underlying Type, methods []*Func) *Named
type Var (struct) A Variable represents a declared variable (including function parameters and results, and struct fields). (*T) Anonymous() bool (*T) Embedded() bool (*T) Exported() bool (*T) Id() string (*T) IsField() bool (*T) Name() string (*T) Parent() *Scope (*T) Pkg() *Package (*T) Pos() token.Pos (*T) String() string (*T) Type() Type *T : Object *T : expvar.Var *T : fmt.Stringer func NewField(pos token.Pos, pkg *Package, name string, typ Type, embedded bool) *Var func NewParam(pos token.Pos, pkg *Package, name string, typ Type) *Var func NewVar(pos token.Pos, pkg *Package, name string, typ Type) *Var func (*Signature).Recv() *Var func (*Struct).Field(i int) *Var func (*Tuple).At(i int) *Var func NewSignature(recv *Var, params, results *Tuple, variadic bool) *Signature func NewStruct(fields []*Var, tags []string) *Struct func NewTuple(x ...*Var) *Tuple func Sizes.Offsetsof(fields []*Var) []int64 func (*StdSizes).Offsetsof(fields []*Var) []int64
Exported Values
func AssertableTo(V *Interface, T Type) bool AssertableTo reports whether a value of type V can be asserted to have type T.
func AssignableTo(V, T Type) bool AssignableTo reports whether a value of type V is assignable to a variable of type T.
const Bool BasicKind = 1 predeclared types
const Byte BasicKind = 8 aliases
func CheckExpr(fset *token.FileSet, pkg *Package, pos token.Pos, expr ast.Expr, info *Info) (err error) CheckExpr type checks the expression expr as if it had appeared at position pos of package pkg. Type information about the expression is recorded in info. If pkg == nil, the Universe scope is used and the provided position pos is ignored. If pkg != nil, and pos is invalid, the package scope is used. Otherwise, pos must belong to the package. An error is returned if pos is not within the package or if the node cannot be type-checked. Note: Eval and CheckExpr should not be used instead of running Check to compute types and values, but in addition to Check, as these functions ignore the context in which an expression is used (e.g., an assignment). Thus, top-level untyped constants will return an untyped type rather then the respective context-specific type.
func Comparable(T Type) bool Comparable reports whether values of type T are comparable.
const Complex128 BasicKind = 16
const Complex64 BasicKind = 15
func ConvertibleTo(V, T Type) bool ConvertibleTo reports whether a value of type V is convertible to a value of type T.
func Default(typ Type) Type Default returns the default "typed" type for an "untyped" type; it returns the incoming type for all other types. The default type for untyped nil is untyped nil.
func DefPredeclaredTestFuncs() DefPredeclaredTestFuncs defines the assert and trace built-ins. These built-ins are intended for debugging and testing of this package only.
func Eval(fset *token.FileSet, pkg *Package, pos token.Pos, expr string) (_ TypeAndValue, err error) Eval returns the type and, if constant, the value for the expression expr, evaluated at position pos of package pkg, which must have been derived from type-checking an AST with complete position information relative to the provided file set. The meaning of the parameters fset, pkg, and pos is the same as in CheckExpr. An error is returned if expr cannot be parsed successfully, or the resulting expr AST cannot be type-checked.
func ExprString(x ast.Expr) string ExprString returns the (possibly shortened) string representation for x. Shortened representations are suitable for user interfaces but may not necessarily follow Go syntax.
const FieldVal SelectionKind = 0 // x.f is a struct field selector
const Float32 BasicKind = 13
const Float64 BasicKind = 14
func Id(pkg *Package, name string) string Id returns name if it is exported, otherwise it returns the name qualified with the package path.
func Identical(x, y Type) bool Identical reports whether x and y are identical types. Receivers of Signature types are ignored.
func IdenticalIgnoreTags(x, y Type) bool IdenticalIgnoreTags reports whether x and y are identical types if tags are ignored. Receivers of Signature types are ignored.
func Implements(V Type, T *Interface) bool Implements reports whether type V implements interface T.
const Int BasicKind = 2
const Int16 BasicKind = 4
const Int32 BasicKind = 5
const Int64 BasicKind = 6
const Int8 BasicKind = 3
const Invalid BasicKind = 0 // type is invalid
const IsBoolean BasicInfo = 1 Properties of basic types.
const IsComplex BasicInfo = 16 Properties of basic types.
const IsConstType BasicInfo = 59 Properties of basic types.
const IsFloat BasicInfo = 8 Properties of basic types.
const IsInteger BasicInfo = 2 Properties of basic types.
func IsInterface(typ Type) bool IsInterface reports whether typ is an interface type.
const IsNumeric BasicInfo = 26 Properties of basic types.
const IsOrdered BasicInfo = 42 Properties of basic types.
const IsString BasicInfo = 32 Properties of basic types.
const IsUnsigned BasicInfo = 4 Properties of basic types.
const IsUntyped BasicInfo = 64 Properties of basic types.
func LookupFieldOrMethod(T Type, addressable bool, pkg *Package, name string) (obj Object, index []int, indirect bool) LookupFieldOrMethod looks up a field or method with given package and name in T and returns the corresponding *Var or *Func, an index sequence, and a bool indicating if there were any pointer indirections on the path to the field or method. If addressable is set, T is the type of an addressable variable (only matters for method lookups). The last index entry is the field or method index in the (possibly embedded) type where the entry was found, either: 1) the list of declared methods of a named type; or 2) the list of all methods (method set) of an interface type; or 3) the list of fields of a struct type. The earlier index entries are the indices of the embedded struct fields traversed to get to the found entry, starting at depth 0. If no entry is found, a nil object is returned. In this case, the returned index and indirect values have the following meaning: - If index != nil, the index sequence points to an ambiguous entry (the same name appeared more than once at the same embedding level). - If indirect is set, a method with a pointer receiver type was found but there was no pointer on the path from the actual receiver type to the method's formal receiver base type, nor was the receiver addressable.
const MethodExpr SelectionKind = 2 // x.f is a method expression
const MethodVal SelectionKind = 1 // x.f is a method selector
func MissingMethod(V Type, T *Interface, static bool) (method *Func, wrongType bool) MissingMethod returns (nil, false) if V implements T, otherwise it returns a missing method required by T and whether it is missing or just has the wrong type. For non-interface types V, or if static is set, V implements T if all methods of T are present in V. Otherwise (V is an interface and static is not set), MissingMethod only checks that methods of T which are also present in V have matching types (e.g., for a type assertion x.(T) where x is of interface type V).
func NewArray(elem Type, len int64) *Array NewArray returns a new array type for the given element type and length. A negative length indicates an unknown length.
func NewChan(dir ChanDir, elem Type) *Chan NewChan returns a new channel type for the given direction and element type.
func NewChecker(conf *Config, fset *token.FileSet, pkg *Package, info *Info) *Checker NewChecker returns a new Checker instance for a given package. Package files may be added incrementally via checker.Files.
func NewConst(pos token.Pos, pkg *Package, name string, typ Type, val constant.Value) *Const NewConst returns a new constant with value val. The remaining arguments set the attributes found with all Objects.
func NewField(pos token.Pos, pkg *Package, name string, typ Type, embedded bool) *Var NewField returns a new variable representing a struct field. For embedded fields, the name is the unqualified type name / under which the field is accessible.
func NewFunc(pos token.Pos, pkg *Package, name string, sig *Signature) *Func NewFunc returns a new function with the given signature, representing the function's type.
func NewInterface(methods []*Func, embeddeds []*Named) *Interface NewInterface returns a new (incomplete) interface for the given methods and embedded types. Each embedded type must have an underlying type of interface type. NewInterface takes ownership of the provided methods and may modify their types by setting missing receivers. To compute the method set of the interface, Complete must be called. Deprecated: Use NewInterfaceType instead which allows any (even non-defined) interface types to be embedded. This is necessary for interfaces that embed alias type names referring to non-defined (literal) interface types.
func NewInterfaceType(methods []*Func, embeddeds []Type) *Interface NewInterfaceType returns a new (incomplete) interface for the given methods and embedded types. Each embedded type must have an underlying type of interface type (this property is not verified for defined types, which may be in the process of being set up and which don't have a valid underlying type yet). NewInterfaceType takes ownership of the provided methods and may modify their types by setting missing receivers. To compute the method set of the interface, Complete must be called.
func NewLabel(pos token.Pos, pkg *Package, name string) *Label NewLabel returns a new label.
func NewMap(key, elem Type) *Map NewMap returns a new map for the given key and element types.
func NewMethodSet(T Type) *MethodSet NewMethodSet returns the method set for the given type T. It always returns a non-nil method set, even if it is empty.
func NewNamed(obj *TypeName, underlying Type, methods []*Func) *Named NewNamed returns a new named type for the given type name, underlying type, and associated methods. If the given type name obj doesn't have a type yet, its type is set to the returned named type. The underlying type must not be a *Named.
func NewPackage(path, name string) *Package NewPackage returns a new Package for the given package path and name. The package is not complete and contains no explicit imports.
func NewParam(pos token.Pos, pkg *Package, name string, typ Type) *Var NewParam returns a new variable representing a function parameter.
func NewPkgName(pos token.Pos, pkg *Package, name string, imported *Package) *PkgName NewPkgName returns a new PkgName object representing an imported package. The remaining arguments set the attributes found with all Objects.
func NewPointer(elem Type) *Pointer NewPointer returns a new pointer type for the given element (base) type.
func NewScope(parent *Scope, pos, end token.Pos, comment string) *Scope NewScope returns a new, empty scope contained in the given parent scope, if any. The comment is for debugging only.
func NewSignature(recv *Var, params, results *Tuple, variadic bool) *Signature NewSignature returns a new function type for the given receiver, parameters, and results, either of which may be nil. If variadic is set, the function is variadic, it must have at least one parameter, and the last parameter must be of unnamed slice type.
func NewSlice(elem Type) *Slice NewSlice returns a new slice type for the given element type.
func NewStruct(fields []*Var, tags []string) *Struct NewStruct returns a new struct with the given fields and corresponding field tags. If a field with index i has a tag, tags[i] must be that tag, but len(tags) may be only as long as required to hold the tag with the largest index i. Consequently, if no field has a tag, tags may be nil.
func NewTuple(x ...*Var) *Tuple NewTuple returns a new tuple for the given variables.
func NewTypeName(pos token.Pos, pkg *Package, name string, typ Type) *TypeName NewTypeName returns a new type name denoting the given typ. The remaining arguments set the attributes found with all Objects. The typ argument may be a defined (Named) type or an alias type. It may also be nil such that the returned TypeName can be used as argument for NewNamed, which will set the TypeName's type as a side- effect.
func NewVar(pos token.Pos, pkg *Package, name string, typ Type) *Var NewVar returns a new variable. The arguments set the attributes found with all Objects.
func ObjectString(obj Object, qf Qualifier) string ObjectString returns the string form of obj. The Qualifier controls the printing of package-level objects, and may be nil.
const RecvOnly ChanDir = 2 The direction of a channel is indicated by one of these constants.
func RelativeTo(pkg *Package) Qualifier RelativeTo returns a Qualifier that fully qualifies members of all packages other than pkg.
const Rune BasicKind = 5
func SelectionString(s *Selection, qf Qualifier) string SelectionString returns the string form of s. The Qualifier controls the printing of package-level objects, and may be nil. Examples: "field (T) f int" "method (T) f(X) Y" "method expr (T) f(X) Y"
const SendOnly ChanDir = 1 The direction of a channel is indicated by one of these constants.
const SendRecv ChanDir = 0 The direction of a channel is indicated by one of these constants.
func SizesFor(compiler, arch string) Sizes SizesFor returns the Sizes used by a compiler for an architecture. The result is nil if a compiler/architecture pair is not known. Supported architectures for compiler "gc": "386", "arm", "arm64", "amd64", "amd64p32", "mips", "mipsle", "mips64", "mips64le", "ppc64", "ppc64le", "riscv64", "s390x", "sparc64", "wasm".
const String BasicKind = 17
var Typ []*Basic Typ contains the predeclared *Basic types indexed by their corresponding BasicKind. The *Basic type for Typ[Byte] will have the name "uint8". Use Universe.Lookup("byte").Type() to obtain the specific alias basic type named "byte" (and analogous for "rune").
func TypeString(typ Type, qf Qualifier) string TypeString returns the string representation of typ. The Qualifier controls the printing of package-level objects, and may be nil.
const Uint BasicKind = 7
const Uint16 BasicKind = 9
const Uint32 BasicKind = 10
const Uint64 BasicKind = 11
const Uint8 BasicKind = 8
const Uintptr BasicKind = 12
var Universe *Scope The Universe scope contains all predeclared objects of Go. It is the outermost scope of any chain of nested scopes.
var Unsafe *Package The Unsafe package is the package returned by an importer for the import path "unsafe".
const UntypedBool BasicKind = 19 types for untyped values
const UntypedInt BasicKind = 20
const UntypedNil BasicKind = 25
func WriteExpr(buf *bytes.Buffer, x ast.Expr) WriteExpr writes the (possibly shortened) string representation for x to buf. Shortened representations are suitable for user interfaces but may not necessarily follow Go syntax.
func WriteSignature(buf *bytes.Buffer, sig *Signature, qf Qualifier) WriteSignature writes the representation of the signature sig to buf, without a leading "func" keyword. The Qualifier controls the printing of package-level objects, and may be nil.
func WriteType(buf *bytes.Buffer, typ Type, qf Qualifier) WriteType writes the string representation of typ to buf. The Qualifier controls the printing of package-level objects, and may be nil.