summaryrefslogtreecommitdiff
path: root/devdocs/go/go%2Ftypes%2Findex.html
diff options
context:
space:
mode:
Diffstat (limited to 'devdocs/go/go%2Ftypes%2Findex.html')
-rw-r--r--devdocs/go/go%2Ftypes%2Findex.html1630
1 files changed, 1630 insertions, 0 deletions
diff --git a/devdocs/go/go%2Ftypes%2Findex.html b/devdocs/go/go%2Ftypes%2Findex.html
new file mode 100644
index 00000000..fed28de7
--- /dev/null
+++ b/devdocs/go/go%2Ftypes%2Findex.html
@@ -0,0 +1,1630 @@
+<h1> Package types </h1> <ul id="short-nav">
+<li><code>import "go/types"</code></li>
+<li><a href="#pkg-overview" class="overviewLink">Overview</a></li>
+<li><a href="#pkg-index" class="indexLink">Index</a></li>
+<li><a href="#pkg-examples" class="examplesLink">Examples</a></li>
+</ul> <h2 id="pkg-overview">Overview </h2> <p>Package types declares the data types and implements the algorithms for type-checking of Go packages. Use <a href="#Config.Check">Config.Check</a> to invoke the type checker for a package. Alternatively, create a new type checker with <a href="#NewChecker">NewChecker</a> and invoke it incrementally by calling <a href="#Checker.Files">Checker.Files</a>. </p>
+<p>Type-checking consists of several interdependent phases: </p>
+<p>Name resolution maps each identifier (ast.Ident) in the program to the language object (<a href="#Object">Object</a>) it denotes. Use <a href="#Info">Info</a>.{Defs,Uses,Implicits} for the results of name resolution. </p>
+<p>Constant folding computes the exact constant value (constant.Value) for every expression (ast.Expr) that is a compile-time constant. Use Info.Types[expr].Value for the results of constant folding. </p>
+<p><a href="#Type">Type</a> inference computes the type (<a href="#Type">Type</a>) of every expression (<span>ast.Expr</span>) and checks for compliance with the language specification. Use [Info.Types][expr].Type for the results of type inference. </p>
+<p>For a tutorial, see <a href="https://golang.org/s/types-tutorial">https://golang.org/s/types-tutorial</a>. </p> <h2 id="pkg-index">Index </h2> <ul id="manual-nav">
+<li><a href="#pkg-variables">Variables</a></li>
+<li><a href="#AssertableTo">func AssertableTo(V *Interface, T Type) bool</a></li>
+<li><a href="#AssignableTo">func AssignableTo(V, T Type) bool</a></li>
+<li><a href="#CheckExpr">func CheckExpr(fset *token.FileSet, pkg *Package, pos token.Pos, expr ast.Expr, info *Info) (err error)</a></li>
+<li><a href="#Comparable">func Comparable(T Type) bool</a></li>
+<li><a href="#ConvertibleTo">func ConvertibleTo(V, T Type) bool</a></li>
+<li><a href="#DefPredeclaredTestFuncs">func DefPredeclaredTestFuncs()</a></li>
+<li><a href="#ExprString">func ExprString(x ast.Expr) string</a></li>
+<li><a href="#Id">func Id(pkg *Package, name string) string</a></li>
+<li><a href="#Identical">func Identical(x, y Type) bool</a></li>
+<li><a href="#IdenticalIgnoreTags">func IdenticalIgnoreTags(x, y Type) bool</a></li>
+<li><a href="#Implements">func Implements(V Type, T *Interface) bool</a></li>
+<li><a href="#IsInterface">func IsInterface(t Type) bool</a></li>
+<li><a href="#ObjectString">func ObjectString(obj Object, qf Qualifier) string</a></li>
+<li><a href="#Satisfies">func Satisfies(V Type, T *Interface) bool</a></li>
+<li><a href="#SelectionString">func SelectionString(s *Selection, qf Qualifier) string</a></li>
+<li><a href="#TypeString">func TypeString(typ Type, qf Qualifier) string</a></li>
+<li><a href="#WriteExpr">func WriteExpr(buf *bytes.Buffer, x ast.Expr)</a></li>
+<li><a href="#WriteSignature">func WriteSignature(buf *bytes.Buffer, sig *Signature, qf Qualifier)</a></li>
+<li><a href="#WriteType">func WriteType(buf *bytes.Buffer, typ Type, qf Qualifier)</a></li>
+<li><a href="#Alias">type Alias</a></li>
+<li> <a href="#NewAlias">func NewAlias(obj *TypeName, rhs Type) *Alias</a>
+</li>
+<li> <a href="#Alias.Obj">func (a *Alias) Obj() *TypeName</a>
+</li>
+<li> <a href="#Alias.String">func (a *Alias) String() string</a>
+</li>
+<li> <a href="#Alias.Underlying">func (a *Alias) Underlying() Type</a>
+</li>
+<li><a href="#ArgumentError">type ArgumentError</a></li>
+<li> <a href="#ArgumentError.Error">func (e *ArgumentError) Error() string</a>
+</li>
+<li> <a href="#ArgumentError.Unwrap">func (e *ArgumentError) Unwrap() error</a>
+</li>
+<li><a href="#Array">type Array</a></li>
+<li> <a href="#NewArray">func NewArray(elem Type, len int64) *Array</a>
+</li>
+<li> <a href="#Array.Elem">func (a *Array) Elem() Type</a>
+</li>
+<li> <a href="#Array.Len">func (a *Array) Len() int64</a>
+</li>
+<li> <a href="#Array.String">func (a *Array) String() string</a>
+</li>
+<li> <a href="#Array.Underlying">func (a *Array) Underlying() Type</a>
+</li>
+<li><a href="#Basic">type Basic</a></li>
+<li> <a href="#Basic.Info">func (b *Basic) Info() BasicInfo</a>
+</li>
+<li> <a href="#Basic.Kind">func (b *Basic) Kind() BasicKind</a>
+</li>
+<li> <a href="#Basic.Name">func (b *Basic) Name() string</a>
+</li>
+<li> <a href="#Basic.String">func (b *Basic) String() string</a>
+</li>
+<li> <a href="#Basic.Underlying">func (b *Basic) Underlying() Type</a>
+</li>
+<li><a href="#BasicInfo">type BasicInfo</a></li>
+<li><a href="#BasicKind">type BasicKind</a></li>
+<li><a href="#Builtin">type Builtin</a></li>
+<li> <a href="#Builtin.Exported">func (obj *Builtin) Exported() bool</a>
+</li>
+<li> <a href="#Builtin.Id">func (obj *Builtin) Id() string</a>
+</li>
+<li> <a href="#Builtin.Name">func (obj *Builtin) Name() string</a>
+</li>
+<li> <a href="#Builtin.Parent">func (obj *Builtin) Parent() *Scope</a>
+</li>
+<li> <a href="#Builtin.Pkg">func (obj *Builtin) Pkg() *Package</a>
+</li>
+<li> <a href="#Builtin.Pos">func (obj *Builtin) Pos() token.Pos</a>
+</li>
+<li> <a href="#Builtin.String">func (obj *Builtin) String() string</a>
+</li>
+<li> <a href="#Builtin.Type">func (obj *Builtin) Type() Type</a>
+</li>
+<li><a href="#Chan">type Chan</a></li>
+<li> <a href="#NewChan">func NewChan(dir ChanDir, elem Type) *Chan</a>
+</li>
+<li> <a href="#Chan.Dir">func (c *Chan) Dir() ChanDir</a>
+</li>
+<li> <a href="#Chan.Elem">func (c *Chan) Elem() Type</a>
+</li>
+<li> <a href="#Chan.String">func (c *Chan) String() string</a>
+</li>
+<li> <a href="#Chan.Underlying">func (c *Chan) Underlying() Type</a>
+</li>
+<li><a href="#ChanDir">type ChanDir</a></li>
+<li><a href="#Checker">type Checker</a></li>
+<li> <a href="#NewChecker">func NewChecker(conf *Config, fset *token.FileSet, pkg *Package, info *Info) *Checker</a>
+</li>
+<li> <a href="#Checker.Files">func (check *Checker) Files(files []*ast.File) error</a>
+</li>
+<li><a href="#Config">type Config</a></li>
+<li> <a href="#Config.Check">func (conf *Config) Check(path string, fset *token.FileSet, files []*ast.File, info *Info) (*Package, error)</a>
+</li>
+<li><a href="#Const">type Const</a></li>
+<li> <a href="#NewConst">func NewConst(pos token.Pos, pkg *Package, name string, typ Type, val constant.Value) *Const</a>
+</li>
+<li> <a href="#Const.Exported">func (obj *Const) Exported() bool</a>
+</li>
+<li> <a href="#Const.Id">func (obj *Const) Id() string</a>
+</li>
+<li> <a href="#Const.Name">func (obj *Const) Name() string</a>
+</li>
+<li> <a href="#Const.Parent">func (obj *Const) Parent() *Scope</a>
+</li>
+<li> <a href="#Const.Pkg">func (obj *Const) Pkg() *Package</a>
+</li>
+<li> <a href="#Const.Pos">func (obj *Const) Pos() token.Pos</a>
+</li>
+<li> <a href="#Const.String">func (obj *Const) String() string</a>
+</li>
+<li> <a href="#Const.Type">func (obj *Const) Type() Type</a>
+</li>
+<li> <a href="#Const.Val">func (obj *Const) Val() constant.Value</a>
+</li>
+<li><a href="#Context">type Context</a></li>
+<li> <a href="#NewContext">func NewContext() *Context</a>
+</li>
+<li><a href="#Error">type Error</a></li>
+<li> <a href="#Error.Error">func (err Error) Error() string</a>
+</li>
+<li><a href="#Func">type Func</a></li>
+<li> <a href="#MissingMethod">func MissingMethod(V Type, T *Interface, static bool) (method *Func, wrongType bool)</a>
+</li>
+<li> <a href="#NewFunc">func NewFunc(pos token.Pos, pkg *Package, name string, sig *Signature) *Func</a>
+</li>
+<li> <a href="#Func.Exported">func (obj *Func) Exported() bool</a>
+</li>
+<li> <a href="#Func.FullName">func (obj *Func) FullName() string</a>
+</li>
+<li> <a href="#Func.Id">func (obj *Func) Id() string</a>
+</li>
+<li> <a href="#Func.Name">func (obj *Func) Name() string</a>
+</li>
+<li> <a href="#Func.Origin">func (obj *Func) Origin() *Func</a>
+</li>
+<li> <a href="#Func.Parent">func (obj *Func) Parent() *Scope</a>
+</li>
+<li> <a href="#Func.Pkg">func (obj *Func) Pkg() *Package</a>
+</li>
+<li> <a href="#Func.Pos">func (obj *Func) Pos() token.Pos</a>
+</li>
+<li> <a href="#Func.Scope">func (obj *Func) Scope() *Scope</a>
+</li>
+<li> <a href="#Func.String">func (obj *Func) String() string</a>
+</li>
+<li> <a href="#Func.Type">func (obj *Func) Type() Type</a>
+</li>
+<li><a href="#ImportMode">type ImportMode</a></li>
+<li><a href="#Importer">type Importer</a></li>
+<li><a href="#ImporterFrom">type ImporterFrom</a></li>
+<li><a href="#Info">type Info</a></li>
+<li> <a href="#Info.ObjectOf">func (info *Info) ObjectOf(id *ast.Ident) Object</a>
+</li>
+<li> <a href="#Info.PkgNameOf">func (info *Info) PkgNameOf(imp *ast.ImportSpec) *PkgName</a>
+</li>
+<li> <a href="#Info.TypeOf">func (info *Info) TypeOf(e ast.Expr) Type</a>
+</li>
+<li><a href="#Initializer">type Initializer</a></li>
+<li> <a href="#Initializer.String">func (init *Initializer) String() string</a>
+</li>
+<li><a href="#Instance">type Instance</a></li>
+<li><a href="#Interface">type Interface</a></li>
+<li> <a href="#NewInterface">func NewInterface(methods []*Func, embeddeds []*Named) *Interface</a>
+</li>
+<li> <a href="#NewInterfaceType">func NewInterfaceType(methods []*Func, embeddeds []Type) *Interface</a>
+</li>
+<li> <a href="#Interface.Complete">func (t *Interface) Complete() *Interface</a>
+</li>
+<li> <a href="#Interface.Embedded">func (t *Interface) Embedded(i int) *Named</a>
+</li>
+<li> <a href="#Interface.EmbeddedType">func (t *Interface) EmbeddedType(i int) Type</a>
+</li>
+<li> <a href="#Interface.Empty">func (t *Interface) Empty() bool</a>
+</li>
+<li> <a href="#Interface.ExplicitMethod">func (t *Interface) ExplicitMethod(i int) *Func</a>
+</li>
+<li> <a href="#Interface.IsComparable">func (t *Interface) IsComparable() bool</a>
+</li>
+<li> <a href="#Interface.IsImplicit">func (t *Interface) IsImplicit() bool</a>
+</li>
+<li> <a href="#Interface.IsMethodSet">func (t *Interface) IsMethodSet() bool</a>
+</li>
+<li> <a href="#Interface.MarkImplicit">func (t *Interface) MarkImplicit()</a>
+</li>
+<li> <a href="#Interface.Method">func (t *Interface) Method(i int) *Func</a>
+</li>
+<li> <a href="#Interface.NumEmbeddeds">func (t *Interface) NumEmbeddeds() int</a>
+</li>
+<li> <a href="#Interface.NumExplicitMethods">func (t *Interface) NumExplicitMethods() int</a>
+</li>
+<li> <a href="#Interface.NumMethods">func (t *Interface) NumMethods() int</a>
+</li>
+<li> <a href="#Interface.String">func (t *Interface) String() string</a>
+</li>
+<li> <a href="#Interface.Underlying">func (t *Interface) Underlying() Type</a>
+</li>
+<li><a href="#Label">type Label</a></li>
+<li> <a href="#NewLabel">func NewLabel(pos token.Pos, pkg *Package, name string) *Label</a>
+</li>
+<li> <a href="#Label.Exported">func (obj *Label) Exported() bool</a>
+</li>
+<li> <a href="#Label.Id">func (obj *Label) Id() string</a>
+</li>
+<li> <a href="#Label.Name">func (obj *Label) Name() string</a>
+</li>
+<li> <a href="#Label.Parent">func (obj *Label) Parent() *Scope</a>
+</li>
+<li> <a href="#Label.Pkg">func (obj *Label) Pkg() *Package</a>
+</li>
+<li> <a href="#Label.Pos">func (obj *Label) Pos() token.Pos</a>
+</li>
+<li> <a href="#Label.String">func (obj *Label) String() string</a>
+</li>
+<li> <a href="#Label.Type">func (obj *Label) Type() Type</a>
+</li>
+<li><a href="#Map">type Map</a></li>
+<li> <a href="#NewMap">func NewMap(key, elem Type) *Map</a>
+</li>
+<li> <a href="#Map.Elem">func (m *Map) Elem() Type</a>
+</li>
+<li> <a href="#Map.Key">func (m *Map) Key() Type</a>
+</li>
+<li> <a href="#Map.String">func (t *Map) String() string</a>
+</li>
+<li> <a href="#Map.Underlying">func (t *Map) Underlying() Type</a>
+</li>
+<li><a href="#MethodSet">type MethodSet</a></li>
+<li> <a href="#NewMethodSet">func NewMethodSet(T Type) *MethodSet</a>
+</li>
+<li> <a href="#MethodSet.At">func (s *MethodSet) At(i int) *Selection</a>
+</li>
+<li> <a href="#MethodSet.Len">func (s *MethodSet) Len() int</a>
+</li>
+<li> <a href="#MethodSet.Lookup">func (s *MethodSet) Lookup(pkg *Package, name string) *Selection</a>
+</li>
+<li> <a href="#MethodSet.String">func (s *MethodSet) String() string</a>
+</li>
+<li><a href="#Named">type Named</a></li>
+<li> <a href="#NewNamed">func NewNamed(obj *TypeName, underlying Type, methods []*Func) *Named</a>
+</li>
+<li> <a href="#Named.AddMethod">func (t *Named) AddMethod(m *Func)</a>
+</li>
+<li> <a href="#Named.Method">func (t *Named) Method(i int) *Func</a>
+</li>
+<li> <a href="#Named.NumMethods">func (t *Named) NumMethods() int</a>
+</li>
+<li> <a href="#Named.Obj">func (t *Named) Obj() *TypeName</a>
+</li>
+<li> <a href="#Named.Origin">func (t *Named) Origin() *Named</a>
+</li>
+<li> <a href="#Named.SetTypeParams">func (t *Named) SetTypeParams(tparams []*TypeParam)</a>
+</li>
+<li> <a href="#Named.SetUnderlying">func (t *Named) SetUnderlying(underlying Type)</a>
+</li>
+<li> <a href="#Named.String">func (t *Named) String() string</a>
+</li>
+<li> <a href="#Named.TypeArgs">func (t *Named) TypeArgs() *TypeList</a>
+</li>
+<li> <a href="#Named.TypeParams">func (t *Named) TypeParams() *TypeParamList</a>
+</li>
+<li> <a href="#Named.Underlying">func (t *Named) Underlying() Type</a>
+</li>
+<li><a href="#Nil">type Nil</a></li>
+<li> <a href="#Nil.Exported">func (obj *Nil) Exported() bool</a>
+</li>
+<li> <a href="#Nil.Id">func (obj *Nil) Id() string</a>
+</li>
+<li> <a href="#Nil.Name">func (obj *Nil) Name() string</a>
+</li>
+<li> <a href="#Nil.Parent">func (obj *Nil) Parent() *Scope</a>
+</li>
+<li> <a href="#Nil.Pkg">func (obj *Nil) Pkg() *Package</a>
+</li>
+<li> <a href="#Nil.Pos">func (obj *Nil) Pos() token.Pos</a>
+</li>
+<li> <a href="#Nil.String">func (obj *Nil) String() string</a>
+</li>
+<li> <a href="#Nil.Type">func (obj *Nil) Type() Type</a>
+</li>
+<li><a href="#Object">type Object</a></li>
+<li> <a href="#LookupFieldOrMethod">func LookupFieldOrMethod(T Type, addressable bool, pkg *Package, name string) (obj Object, index []int, indirect bool)</a>
+</li>
+<li><a href="#Package">type Package</a></li>
+<li> <a href="#NewPackage">func NewPackage(path, name string) *Package</a>
+</li>
+<li> <a href="#Package.Complete">func (pkg *Package) Complete() bool</a>
+</li>
+<li> <a href="#Package.GoVersion">func (pkg *Package) GoVersion() string</a>
+</li>
+<li> <a href="#Package.Imports">func (pkg *Package) Imports() []*Package</a>
+</li>
+<li> <a href="#Package.MarkComplete">func (pkg *Package) MarkComplete()</a>
+</li>
+<li> <a href="#Package.Name">func (pkg *Package) Name() string</a>
+</li>
+<li> <a href="#Package.Path">func (pkg *Package) Path() string</a>
+</li>
+<li> <a href="#Package.Scope">func (pkg *Package) Scope() *Scope</a>
+</li>
+<li> <a href="#Package.SetImports">func (pkg *Package) SetImports(list []*Package)</a>
+</li>
+<li> <a href="#Package.SetName">func (pkg *Package) SetName(name string)</a>
+</li>
+<li> <a href="#Package.String">func (pkg *Package) String() string</a>
+</li>
+<li><a href="#PkgName">type PkgName</a></li>
+<li> <a href="#NewPkgName">func NewPkgName(pos token.Pos, pkg *Package, name string, imported *Package) *PkgName</a>
+</li>
+<li> <a href="#PkgName.Exported">func (obj *PkgName) Exported() bool</a>
+</li>
+<li> <a href="#PkgName.Id">func (obj *PkgName) Id() string</a>
+</li>
+<li> <a href="#PkgName.Imported">func (obj *PkgName) Imported() *Package</a>
+</li>
+<li> <a href="#PkgName.Name">func (obj *PkgName) Name() string</a>
+</li>
+<li> <a href="#PkgName.Parent">func (obj *PkgName) Parent() *Scope</a>
+</li>
+<li> <a href="#PkgName.Pkg">func (obj *PkgName) Pkg() *Package</a>
+</li>
+<li> <a href="#PkgName.Pos">func (obj *PkgName) Pos() token.Pos</a>
+</li>
+<li> <a href="#PkgName.String">func (obj *PkgName) String() string</a>
+</li>
+<li> <a href="#PkgName.Type">func (obj *PkgName) Type() Type</a>
+</li>
+<li><a href="#Pointer">type Pointer</a></li>
+<li> <a href="#NewPointer">func NewPointer(elem Type) *Pointer</a>
+</li>
+<li> <a href="#Pointer.Elem">func (p *Pointer) Elem() Type</a>
+</li>
+<li> <a href="#Pointer.String">func (p *Pointer) String() string</a>
+</li>
+<li> <a href="#Pointer.Underlying">func (p *Pointer) Underlying() Type</a>
+</li>
+<li><a href="#Qualifier">type Qualifier</a></li>
+<li> <a href="#RelativeTo">func RelativeTo(pkg *Package) Qualifier</a>
+</li>
+<li><a href="#Scope">type Scope</a></li>
+<li> <a href="#NewScope">func NewScope(parent *Scope, pos, end token.Pos, comment string) *Scope</a>
+</li>
+<li> <a href="#Scope.Child">func (s *Scope) Child(i int) *Scope</a>
+</li>
+<li> <a href="#Scope.Contains">func (s *Scope) Contains(pos token.Pos) bool</a>
+</li>
+<li> <a href="#Scope.End">func (s *Scope) End() token.Pos</a>
+</li>
+<li> <a href="#Scope.Innermost">func (s *Scope) Innermost(pos token.Pos) *Scope</a>
+</li>
+<li> <a href="#Scope.Insert">func (s *Scope) Insert(obj Object) Object</a>
+</li>
+<li> <a href="#Scope.Len">func (s *Scope) Len() int</a>
+</li>
+<li> <a href="#Scope.Lookup">func (s *Scope) Lookup(name string) Object</a>
+</li>
+<li> <a href="#Scope.LookupParent">func (s *Scope) LookupParent(name string, pos token.Pos) (*Scope, Object)</a>
+</li>
+<li> <a href="#Scope.Names">func (s *Scope) Names() []string</a>
+</li>
+<li> <a href="#Scope.NumChildren">func (s *Scope) NumChildren() int</a>
+</li>
+<li> <a href="#Scope.Parent">func (s *Scope) Parent() *Scope</a>
+</li>
+<li> <a href="#Scope.Pos">func (s *Scope) Pos() token.Pos</a>
+</li>
+<li> <a href="#Scope.String">func (s *Scope) String() string</a>
+</li>
+<li> <a href="#Scope.WriteTo">func (s *Scope) WriteTo(w io.Writer, n int, recurse bool)</a>
+</li>
+<li><a href="#Selection">type Selection</a></li>
+<li> <a href="#Selection.Index">func (s *Selection) Index() []int</a>
+</li>
+<li> <a href="#Selection.Indirect">func (s *Selection) Indirect() bool</a>
+</li>
+<li> <a href="#Selection.Kind">func (s *Selection) Kind() SelectionKind</a>
+</li>
+<li> <a href="#Selection.Obj">func (s *Selection) Obj() Object</a>
+</li>
+<li> <a href="#Selection.Recv">func (s *Selection) Recv() Type</a>
+</li>
+<li> <a href="#Selection.String">func (s *Selection) String() string</a>
+</li>
+<li> <a href="#Selection.Type">func (s *Selection) Type() Type</a>
+</li>
+<li><a href="#SelectionKind">type SelectionKind</a></li>
+<li><a href="#Signature">type Signature</a></li>
+<li> <a href="#NewSignature">func NewSignature(recv *Var, params, results *Tuple, variadic bool) *Signature</a>
+</li>
+<li> <a href="#NewSignatureType">func NewSignatureType(recv *Var, recvTypeParams, typeParams []*TypeParam, params, results *Tuple, variadic bool) *Signature</a>
+</li>
+<li> <a href="#Signature.Params">func (s *Signature) Params() *Tuple</a>
+</li>
+<li> <a href="#Signature.Recv">func (s *Signature) Recv() *Var</a>
+</li>
+<li> <a href="#Signature.RecvTypeParams">func (s *Signature) RecvTypeParams() *TypeParamList</a>
+</li>
+<li> <a href="#Signature.Results">func (s *Signature) Results() *Tuple</a>
+</li>
+<li> <a href="#Signature.String">func (t *Signature) String() string</a>
+</li>
+<li> <a href="#Signature.TypeParams">func (s *Signature) TypeParams() *TypeParamList</a>
+</li>
+<li> <a href="#Signature.Underlying">func (t *Signature) Underlying() Type</a>
+</li>
+<li> <a href="#Signature.Variadic">func (s *Signature) Variadic() bool</a>
+</li>
+<li><a href="#Sizes">type Sizes</a></li>
+<li> <a href="#SizesFor">func SizesFor(compiler, arch string) Sizes</a>
+</li>
+<li><a href="#Slice">type Slice</a></li>
+<li> <a href="#NewSlice">func NewSlice(elem Type) *Slice</a>
+</li>
+<li> <a href="#Slice.Elem">func (s *Slice) Elem() Type</a>
+</li>
+<li> <a href="#Slice.String">func (s *Slice) String() string</a>
+</li>
+<li> <a href="#Slice.Underlying">func (s *Slice) Underlying() Type</a>
+</li>
+<li><a href="#StdSizes">type StdSizes</a></li>
+<li> <a href="#StdSizes.Alignof">func (s *StdSizes) Alignof(T Type) (result int64)</a>
+</li>
+<li> <a href="#StdSizes.Offsetsof">func (s *StdSizes) Offsetsof(fields []*Var) []int64</a>
+</li>
+<li> <a href="#StdSizes.Sizeof">func (s *StdSizes) Sizeof(T Type) int64</a>
+</li>
+<li><a href="#Struct">type Struct</a></li>
+<li> <a href="#NewStruct">func NewStruct(fields []*Var, tags []string) *Struct</a>
+</li>
+<li> <a href="#Struct.Field">func (s *Struct) Field(i int) *Var</a>
+</li>
+<li> <a href="#Struct.NumFields">func (s *Struct) NumFields() int</a>
+</li>
+<li> <a href="#Struct.String">func (t *Struct) String() string</a>
+</li>
+<li> <a href="#Struct.Tag">func (s *Struct) Tag(i int) string</a>
+</li>
+<li> <a href="#Struct.Underlying">func (t *Struct) Underlying() Type</a>
+</li>
+<li><a href="#Term">type Term</a></li>
+<li> <a href="#NewTerm">func NewTerm(tilde bool, typ Type) *Term</a>
+</li>
+<li> <a href="#Term.String">func (t *Term) String() string</a>
+</li>
+<li> <a href="#Term.Tilde">func (t *Term) Tilde() bool</a>
+</li>
+<li> <a href="#Term.Type">func (t *Term) Type() Type</a>
+</li>
+<li><a href="#Tuple">type Tuple</a></li>
+<li> <a href="#NewTuple">func NewTuple(x ...*Var) *Tuple</a>
+</li>
+<li> <a href="#Tuple.At">func (t *Tuple) At(i int) *Var</a>
+</li>
+<li> <a href="#Tuple.Len">func (t *Tuple) Len() int</a>
+</li>
+<li> <a href="#Tuple.String">func (t *Tuple) String() string</a>
+</li>
+<li> <a href="#Tuple.Underlying">func (t *Tuple) Underlying() Type</a>
+</li>
+<li><a href="#Type">type Type</a></li>
+<li> <a href="#Default">func Default(t Type) Type</a>
+</li>
+<li> <a href="#Instantiate">func Instantiate(ctxt *Context, orig Type, targs []Type, validate bool) (Type, error)</a>
+</li>
+<li> <a href="#Unalias">func Unalias(t Type) Type</a>
+</li>
+<li><a href="#TypeAndValue">type TypeAndValue</a></li>
+<li> <a href="#Eval">func Eval(fset *token.FileSet, pkg *Package, pos token.Pos, expr string) (_ TypeAndValue, err error)</a>
+</li>
+<li> <a href="#TypeAndValue.Addressable">func (tv TypeAndValue) Addressable() bool</a>
+</li>
+<li> <a href="#TypeAndValue.Assignable">func (tv TypeAndValue) Assignable() bool</a>
+</li>
+<li> <a href="#TypeAndValue.HasOk">func (tv TypeAndValue) HasOk() bool</a>
+</li>
+<li> <a href="#TypeAndValue.IsBuiltin">func (tv TypeAndValue) IsBuiltin() bool</a>
+</li>
+<li> <a href="#TypeAndValue.IsNil">func (tv TypeAndValue) IsNil() bool</a>
+</li>
+<li> <a href="#TypeAndValue.IsType">func (tv TypeAndValue) IsType() bool</a>
+</li>
+<li> <a href="#TypeAndValue.IsValue">func (tv TypeAndValue) IsValue() bool</a>
+</li>
+<li> <a href="#TypeAndValue.IsVoid">func (tv TypeAndValue) IsVoid() bool</a>
+</li>
+<li><a href="#TypeList">type TypeList</a></li>
+<li> <a href="#TypeList.At">func (l *TypeList) At(i int) Type</a>
+</li>
+<li> <a href="#TypeList.Len">func (l *TypeList) Len() int</a>
+</li>
+<li><a href="#TypeName">type TypeName</a></li>
+<li> <a href="#NewTypeName">func NewTypeName(pos token.Pos, pkg *Package, name string, typ Type) *TypeName</a>
+</li>
+<li> <a href="#TypeName.Exported">func (obj *TypeName) Exported() bool</a>
+</li>
+<li> <a href="#TypeName.Id">func (obj *TypeName) Id() string</a>
+</li>
+<li> <a href="#TypeName.IsAlias">func (obj *TypeName) IsAlias() bool</a>
+</li>
+<li> <a href="#TypeName.Name">func (obj *TypeName) Name() string</a>
+</li>
+<li> <a href="#TypeName.Parent">func (obj *TypeName) Parent() *Scope</a>
+</li>
+<li> <a href="#TypeName.Pkg">func (obj *TypeName) Pkg() *Package</a>
+</li>
+<li> <a href="#TypeName.Pos">func (obj *TypeName) Pos() token.Pos</a>
+</li>
+<li> <a href="#TypeName.String">func (obj *TypeName) String() string</a>
+</li>
+<li> <a href="#TypeName.Type">func (obj *TypeName) Type() Type</a>
+</li>
+<li><a href="#TypeParam">type TypeParam</a></li>
+<li> <a href="#NewTypeParam">func NewTypeParam(obj *TypeName, constraint Type) *TypeParam</a>
+</li>
+<li> <a href="#TypeParam.Constraint">func (t *TypeParam) Constraint() Type</a>
+</li>
+<li> <a href="#TypeParam.Index">func (t *TypeParam) Index() int</a>
+</li>
+<li> <a href="#TypeParam.Obj">func (t *TypeParam) Obj() *TypeName</a>
+</li>
+<li> <a href="#TypeParam.SetConstraint">func (t *TypeParam) SetConstraint(bound Type)</a>
+</li>
+<li> <a href="#TypeParam.String">func (t *TypeParam) String() string</a>
+</li>
+<li> <a href="#TypeParam.Underlying">func (t *TypeParam) Underlying() Type</a>
+</li>
+<li><a href="#TypeParamList">type TypeParamList</a></li>
+<li> <a href="#TypeParamList.At">func (l *TypeParamList) At(i int) *TypeParam</a>
+</li>
+<li> <a href="#TypeParamList.Len">func (l *TypeParamList) Len() int</a>
+</li>
+<li><a href="#Union">type Union</a></li>
+<li> <a href="#NewUnion">func NewUnion(terms []*Term) *Union</a>
+</li>
+<li> <a href="#Union.Len">func (u *Union) Len() int</a>
+</li>
+<li> <a href="#Union.String">func (u *Union) String() string</a>
+</li>
+<li> <a href="#Union.Term">func (u *Union) Term(i int) *Term</a>
+</li>
+<li> <a href="#Union.Underlying">func (u *Union) Underlying() Type</a>
+</li>
+<li><a href="#Var">type Var</a></li>
+<li> <a href="#NewField">func NewField(pos token.Pos, pkg *Package, name string, typ Type, embedded bool) *Var</a>
+</li>
+<li> <a href="#NewParam">func NewParam(pos token.Pos, pkg *Package, name string, typ Type) *Var</a>
+</li>
+<li> <a href="#NewVar">func NewVar(pos token.Pos, pkg *Package, name string, typ Type) *Var</a>
+</li>
+<li> <a href="#Var.Anonymous">func (obj *Var) Anonymous() bool</a>
+</li>
+<li> <a href="#Var.Embedded">func (obj *Var) Embedded() bool</a>
+</li>
+<li> <a href="#Var.Exported">func (obj *Var) Exported() bool</a>
+</li>
+<li> <a href="#Var.Id">func (obj *Var) Id() string</a>
+</li>
+<li> <a href="#Var.IsField">func (obj *Var) IsField() bool</a>
+</li>
+<li> <a href="#Var.Name">func (obj *Var) Name() string</a>
+</li>
+<li> <a href="#Var.Origin">func (obj *Var) Origin() *Var</a>
+</li>
+<li> <a href="#Var.Parent">func (obj *Var) Parent() *Scope</a>
+</li>
+<li> <a href="#Var.Pkg">func (obj *Var) Pkg() *Package</a>
+</li>
+<li> <a href="#Var.Pos">func (obj *Var) Pos() token.Pos</a>
+</li>
+<li> <a href="#Var.String">func (obj *Var) String() string</a>
+</li>
+<li> <a href="#Var.Type">func (obj *Var) Type() Type</a>
+</li>
+</ul> <div id="pkg-examples"> <h3>Examples</h3> <dl> <dd><a class="exampleLink" href="#example_Info">Info</a></dd> <dd><a class="exampleLink" href="#example_MethodSet">MethodSet</a></dd> <dd><a class="exampleLink" href="#example_Scope">Scope</a></dd> </dl> </div> <h3>Package files</h3> <p> <span>alias.go</span> <span>api.go</span> <span>api_predicates.go</span> <span>array.go</span> <span>assignments.go</span> <span>basic.go</span> <span>builtins.go</span> <span>call.go</span> <span>chan.go</span> <span>check.go</span> <span>const.go</span> <span>context.go</span> <span>conversions.go</span> <span>decl.go</span> <span>errors.go</span> <span>eval.go</span> <span>expr.go</span> <span>exprstring.go</span> <span>gccgosizes.go</span> <span>gcsizes.go</span> <span>generate.go</span> <span>index.go</span> <span>infer.go</span> <span>initorder.go</span> <span>instantiate.go</span> <span>interface.go</span> <span>labels.go</span> <span>lookup.go</span> <span>map.go</span> <span>methodset.go</span> <span>mono.go</span> <span>named.go</span> <span>object.go</span> <span>objset.go</span> <span>operand.go</span> <span>package.go</span> <span>pointer.go</span> <span>predicates.go</span> <span>resolver.go</span> <span>return.go</span> <span>scope.go</span> <span>selection.go</span> <span>signature.go</span> <span>sizes.go</span> <span>slice.go</span> <span>stmt.go</span> <span>struct.go</span> <span>subst.go</span> <span>termlist.go</span> <span>tuple.go</span> <span>type.go</span> <span>typelists.go</span> <span>typeparam.go</span> <span>typeset.go</span> <span>typestring.go</span> <span>typeterm.go</span> <span>typexpr.go</span> <span>under.go</span> <span>unify.go</span> <span>union.go</span> <span>universe.go</span> <span>util.go</span> <span>validtype.go</span> <span>version.go</span> </p> <h2 id="pkg-variables">Variables</h2> <p>Typ contains the predeclared *Basic types indexed by their corresponding BasicKind. </p>
+<p>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"). </p>
+<pre data-language="go">var Typ = []*Basic{
+ Invalid: {Invalid, 0, "invalid type"},
+
+ Bool: {Bool, IsBoolean, "bool"},
+ Int: {Int, IsInteger, "int"},
+ Int8: {Int8, IsInteger, "int8"},
+ Int16: {Int16, IsInteger, "int16"},
+ Int32: {Int32, IsInteger, "int32"},
+ Int64: {Int64, IsInteger, "int64"},
+ Uint: {Uint, IsInteger | IsUnsigned, "uint"},
+ Uint8: {Uint8, IsInteger | IsUnsigned, "uint8"},
+ Uint16: {Uint16, IsInteger | IsUnsigned, "uint16"},
+ Uint32: {Uint32, IsInteger | IsUnsigned, "uint32"},
+ Uint64: {Uint64, IsInteger | IsUnsigned, "uint64"},
+ Uintptr: {Uintptr, IsInteger | IsUnsigned, "uintptr"},
+ Float32: {Float32, IsFloat, "float32"},
+ Float64: {Float64, IsFloat, "float64"},
+ Complex64: {Complex64, IsComplex, "complex64"},
+ Complex128: {Complex128, IsComplex, "complex128"},
+ String: {String, IsString, "string"},
+ UnsafePointer: {UnsafePointer, 0, "Pointer"},
+
+ UntypedBool: {UntypedBool, IsBoolean | IsUntyped, "untyped bool"},
+ UntypedInt: {UntypedInt, IsInteger | IsUntyped, "untyped int"},
+ UntypedRune: {UntypedRune, IsInteger | IsUntyped, "untyped rune"},
+ UntypedFloat: {UntypedFloat, IsFloat | IsUntyped, "untyped float"},
+ UntypedComplex: {UntypedComplex, IsComplex | IsUntyped, "untyped complex"},
+ UntypedString: {UntypedString, IsString | IsUntyped, "untyped string"},
+ UntypedNil: {UntypedNil, IsUntyped, "untyped nil"},
+}</pre> <h2 id="AssertableTo">func <span>AssertableTo</span> <span title="Added in Go 1.5">1.5</span> </h2> <pre data-language="go">func AssertableTo(V *Interface, T Type) bool</pre> <p>AssertableTo reports whether a value of type V can be asserted to have type T. </p>
+<p>The behavior of AssertableTo is unspecified in three cases: </p>
+<ul> <li>if T is Typ[Invalid] </li>
+<li>if V is a generalized interface; i.e., an interface that may only be used as a type constraint in Go code </li>
+<li>if T is an uninstantiated generic type </li>
+</ul> <h2 id="AssignableTo">func <span>AssignableTo</span> <span title="Added in Go 1.5">1.5</span> </h2> <pre data-language="go">func AssignableTo(V, T Type) bool</pre> <p>AssignableTo reports whether a value of type V is assignable to a variable of type T. </p>
+<p>The behavior of AssignableTo is unspecified if V or T is Typ[Invalid] or an uninstantiated generic type. </p>
+<h2 id="CheckExpr">func <span>CheckExpr</span> <span title="Added in Go 1.13">1.13</span> </h2> <pre data-language="go">func CheckExpr(fset *token.FileSet, pkg *Package, pos token.Pos, expr ast.Expr, info *Info) (err error)</pre> <p>CheckExpr type checks the expression expr as if it had appeared at position pos of package pkg. <a href="#Type">Type</a> information about the expression is recorded in info. The expression may be an identifier denoting an uninstantiated generic function or type. </p>
+<p>If pkg == nil, the <a href="#Universe">Universe</a> 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. </p>
+<p>An error is returned if pos is not within the package or if the node cannot be type-checked. </p>
+<p>Note: <a href="#Eval">Eval</a> 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 than the respective context-specific type. </p>
+<h2 id="Comparable">func <span>Comparable</span> <span title="Added in Go 1.5">1.5</span> </h2> <pre data-language="go">func Comparable(T Type) bool</pre> <p>Comparable reports whether values of type T are comparable. </p>
+<h2 id="ConvertibleTo">func <span>ConvertibleTo</span> <span title="Added in Go 1.5">1.5</span> </h2> <pre data-language="go">func ConvertibleTo(V, T Type) bool</pre> <p>ConvertibleTo reports whether a value of type V is convertible to a value of type T. </p>
+<p>The behavior of ConvertibleTo is unspecified if V or T is Typ[Invalid] or an uninstantiated generic type. </p>
+<h2 id="DefPredeclaredTestFuncs">func <span>DefPredeclaredTestFuncs</span> <span title="Added in Go 1.5">1.5</span> </h2> <pre data-language="go">func DefPredeclaredTestFuncs()</pre> <p>DefPredeclaredTestFuncs defines the assert and trace built-ins. These built-ins are intended for debugging and testing of this package only. </p>
+<h2 id="ExprString">func <span>ExprString</span> <span title="Added in Go 1.5">1.5</span> </h2> <pre data-language="go">func ExprString(x ast.Expr) string</pre> <p>ExprString returns the (possibly shortened) string representation for x. Shortened representations are suitable for user interfaces but may not necessarily follow Go syntax. </p>
+<h2 id="Id">func <span>Id</span> <span title="Added in Go 1.5">1.5</span> </h2> <pre data-language="go">func Id(pkg *Package, name string) string</pre> <p>Id returns name if it is exported, otherwise it returns the name qualified with the package path. </p>
+<h2 id="Identical">func <span>Identical</span> <span title="Added in Go 1.5">1.5</span> </h2> <pre data-language="go">func Identical(x, y Type) bool</pre> <p>Identical reports whether x and y are identical types. Receivers of <a href="#Signature">Signature</a> types are ignored. </p>
+<h2 id="IdenticalIgnoreTags">func <span>IdenticalIgnoreTags</span> <span title="Added in Go 1.8">1.8</span> </h2> <pre data-language="go">func IdenticalIgnoreTags(x, y Type) bool</pre> <p>IdenticalIgnoreTags reports whether x and y are identical types if tags are ignored. Receivers of <a href="#Signature">Signature</a> types are ignored. </p>
+<h2 id="Implements">func <span>Implements</span> <span title="Added in Go 1.5">1.5</span> </h2> <pre data-language="go">func Implements(V Type, T *Interface) bool</pre> <p>Implements reports whether type V implements interface T. </p>
+<p>The behavior of Implements is unspecified if V is Typ[Invalid] or an uninstantiated generic type. </p>
+<h2 id="IsInterface">func <span>IsInterface</span> <span title="Added in Go 1.5">1.5</span> </h2> <pre data-language="go">func IsInterface(t Type) bool</pre> <p>IsInterface reports whether t is an interface type. </p>
+<h2 id="ObjectString">func <span>ObjectString</span> <span title="Added in Go 1.5">1.5</span> </h2> <pre data-language="go">func ObjectString(obj Object, qf Qualifier) string</pre> <p>ObjectString returns the string form of obj. The Qualifier controls the printing of package-level objects, and may be nil. </p>
+<h2 id="Satisfies">func <span>Satisfies</span> <span title="Added in Go 1.20">1.20</span> </h2> <pre data-language="go">func Satisfies(V Type, T *Interface) bool</pre> <p>Satisfies reports whether type V satisfies the constraint T. </p>
+<p>The behavior of Satisfies is unspecified if V is Typ[Invalid] or an uninstantiated generic type. </p>
+<h2 id="SelectionString">func <span>SelectionString</span> <span title="Added in Go 1.5">1.5</span> </h2> <pre data-language="go">func SelectionString(s *Selection, qf Qualifier) string</pre> <p>SelectionString returns the string form of s. The Qualifier controls the printing of package-level objects, and may be nil. </p>
+<p>Examples: </p>
+<pre data-language="go">"field (T) f int"
+"method (T) f(X) Y"
+"method expr (T) f(X) Y"
+</pre> <h2 id="TypeString">func <span>TypeString</span> <span title="Added in Go 1.5">1.5</span> </h2> <pre data-language="go">func TypeString(typ Type, qf Qualifier) string</pre> <p>TypeString returns the string representation of typ. The <a href="#Qualifier">Qualifier</a> controls the printing of package-level objects, and may be nil. </p>
+<h2 id="WriteExpr">func <span>WriteExpr</span> <span title="Added in Go 1.5">1.5</span> </h2> <pre data-language="go">func WriteExpr(buf *bytes.Buffer, x ast.Expr)</pre> <p>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. </p>
+<h2 id="WriteSignature">func <span>WriteSignature</span> <span title="Added in Go 1.5">1.5</span> </h2> <pre data-language="go">func WriteSignature(buf *bytes.Buffer, sig *Signature, qf Qualifier)</pre> <p>WriteSignature writes the representation of the signature sig to buf, without a leading "func" keyword. The <a href="#Qualifier">Qualifier</a> controls the printing of package-level objects, and may be nil. </p>
+<h2 id="WriteType">func <span>WriteType</span> <span title="Added in Go 1.5">1.5</span> </h2> <pre data-language="go">func WriteType(buf *bytes.Buffer, typ Type, qf Qualifier)</pre> <p>WriteType writes the string representation of typ to buf. The <a href="#Qualifier">Qualifier</a> controls the printing of package-level objects, and may be nil. </p>
+<h2 id="Alias">type <span>Alias</span> <span title="Added in Go 1.22">1.22</span> </h2> <p>An Alias represents an alias type. Whether or not Alias types are created is controlled by the gotypesalias setting with the GODEBUG environment variable. For gotypesalias=1, alias declarations produce an Alias type. Otherwise, the alias information is only in the type name, which points directly to the actual (aliased) type. </p>
+<pre data-language="go">type Alias struct {
+ // contains filtered or unexported fields
+}
+</pre> <h3 id="NewAlias">func <span>NewAlias</span> <span title="Added in Go 1.22">1.22</span> </h3> <pre data-language="go">func NewAlias(obj *TypeName, rhs Type) *Alias</pre> <p>NewAlias creates a new Alias type with the given type name and rhs. rhs must not be nil. </p>
+<h3 id="Alias.Obj">func (*Alias) <span>Obj</span> <span title="Added in Go 1.22">1.22</span> </h3> <pre data-language="go">func (a *Alias) Obj() *TypeName</pre> <h3 id="Alias.String">func (*Alias) <span>String</span> <span title="Added in Go 1.22">1.22</span> </h3> <pre data-language="go">func (a *Alias) String() string</pre> <h3 id="Alias.Underlying">func (*Alias) <span>Underlying</span> <span title="Added in Go 1.22">1.22</span> </h3> <pre data-language="go">func (a *Alias) Underlying() Type</pre> <h2 id="ArgumentError">type <span>ArgumentError</span> <span title="Added in Go 1.18">1.18</span> </h2> <p>An ArgumentError holds an error associated with an argument index. </p>
+<pre data-language="go">type ArgumentError struct {
+ Index int
+ Err error
+}
+</pre> <h3 id="ArgumentError.Error">func (*ArgumentError) <span>Error</span> <span title="Added in Go 1.18">1.18</span> </h3> <pre data-language="go">func (e *ArgumentError) Error() string</pre> <h3 id="ArgumentError.Unwrap">func (*ArgumentError) <span>Unwrap</span> <span title="Added in Go 1.18">1.18</span> </h3> <pre data-language="go">func (e *ArgumentError) Unwrap() error</pre> <h2 id="Array">type <span>Array</span> <span title="Added in Go 1.5">1.5</span> </h2> <p>An Array represents an array type. </p>
+<pre data-language="go">type Array struct {
+ // contains filtered or unexported fields
+}
+</pre> <h3 id="NewArray">func <span>NewArray</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func NewArray(elem Type, len int64) *Array</pre> <p>NewArray returns a new array type for the given element type and length. A negative length indicates an unknown length. </p>
+<h3 id="Array.Elem">func (*Array) <span>Elem</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (a *Array) Elem() Type</pre> <p>Elem returns element type of array a. </p>
+<h3 id="Array.Len">func (*Array) <span>Len</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (a *Array) Len() int64</pre> <p>Len returns the length of array a. A negative result indicates an unknown length. </p>
+<h3 id="Array.String">func (*Array) <span>String</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (a *Array) String() string</pre> <h3 id="Array.Underlying">func (*Array) <span>Underlying</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (a *Array) Underlying() Type</pre> <h2 id="Basic">type <span>Basic</span> <span title="Added in Go 1.5">1.5</span> </h2> <p>A Basic represents a basic type. </p>
+<pre data-language="go">type Basic struct {
+ // contains filtered or unexported fields
+}
+</pre> <h3 id="Basic.Info">func (*Basic) <span>Info</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (b *Basic) Info() BasicInfo</pre> <p>Info returns information about properties of basic type b. </p>
+<h3 id="Basic.Kind">func (*Basic) <span>Kind</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (b *Basic) Kind() BasicKind</pre> <p>Kind returns the kind of basic type b. </p>
+<h3 id="Basic.Name">func (*Basic) <span>Name</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (b *Basic) Name() string</pre> <p>Name returns the name of basic type b. </p>
+<h3 id="Basic.String">func (*Basic) <span>String</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (b *Basic) String() string</pre> <h3 id="Basic.Underlying">func (*Basic) <span>Underlying</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (b *Basic) Underlying() Type</pre> <h2 id="BasicInfo">type <span>BasicInfo</span> <span title="Added in Go 1.5">1.5</span> </h2> <p>BasicInfo is a set of flags describing properties of a basic type. </p>
+<pre data-language="go">type BasicInfo int</pre> <p>Properties of basic types. </p>
+<pre data-language="go">const (
+ IsBoolean BasicInfo = 1 &lt;&lt; iota
+ IsInteger
+ IsUnsigned
+ IsFloat
+ IsComplex
+ IsString
+ IsUntyped
+
+ IsOrdered = IsInteger | IsFloat | IsString
+ IsNumeric = IsInteger | IsFloat | IsComplex
+ IsConstType = IsBoolean | IsNumeric | IsString
+)</pre> <h2 id="BasicKind">type <span>BasicKind</span> <span title="Added in Go 1.5">1.5</span> </h2> <p>BasicKind describes the kind of basic type. </p>
+<pre data-language="go">type BasicKind int</pre> <pre data-language="go">const (
+ Invalid BasicKind = iota // type is invalid
+
+ // predeclared types
+ Bool
+ Int
+ Int8
+ Int16
+ Int32
+ Int64
+ Uint
+ Uint8
+ Uint16
+ Uint32
+ Uint64
+ Uintptr
+ Float32
+ Float64
+ Complex64
+ Complex128
+ String
+ UnsafePointer
+
+ // types for untyped values
+ UntypedBool
+ UntypedInt
+ UntypedRune
+ UntypedFloat
+ UntypedComplex
+ UntypedString
+ UntypedNil
+
+ // aliases
+ Byte = Uint8
+ Rune = Int32
+)</pre> <h2 id="Builtin">type <span>Builtin</span> <span title="Added in Go 1.5">1.5</span> </h2> <p>A Builtin represents a built-in function. Builtins don't have a valid type. </p>
+<pre data-language="go">type Builtin struct {
+ // contains filtered or unexported fields
+}
+</pre> <h3 id="Builtin.Exported">func (*Builtin) <span>Exported</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (obj *Builtin) Exported() bool</pre> <p>Exported reports whether the object is exported (starts with a capital letter). It doesn't take into account whether the object is in a local (function) scope or not. </p>
+<h3 id="Builtin.Id">func (*Builtin) <span>Id</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (obj *Builtin) Id() string</pre> <p>Id is a wrapper for Id(obj.Pkg(), obj.Name()). </p>
+<h3 id="Builtin.Name">func (*Builtin) <span>Name</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (obj *Builtin) Name() string</pre> <p>Name returns the object's (package-local, unqualified) name. </p>
+<h3 id="Builtin.Parent">func (*Builtin) <span>Parent</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (obj *Builtin) Parent() *Scope</pre> <p>Parent returns the scope in which the object is declared. The result is nil for methods and struct fields. </p>
+<h3 id="Builtin.Pkg">func (*Builtin) <span>Pkg</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (obj *Builtin) Pkg() *Package</pre> <p>Pkg returns the package to which the object belongs. The result is nil for labels and objects in the Universe scope. </p>
+<h3 id="Builtin.Pos">func (*Builtin) <span>Pos</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (obj *Builtin) Pos() token.Pos</pre> <p>Pos returns the declaration position of the object's identifier. </p>
+<h3 id="Builtin.String">func (*Builtin) <span>String</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (obj *Builtin) String() string</pre> <h3 id="Builtin.Type">func (*Builtin) <span>Type</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (obj *Builtin) Type() Type</pre> <p>Type returns the object's type. </p>
+<h2 id="Chan">type <span>Chan</span> <span title="Added in Go 1.5">1.5</span> </h2> <p>A Chan represents a channel type. </p>
+<pre data-language="go">type Chan struct {
+ // contains filtered or unexported fields
+}
+</pre> <h3 id="NewChan">func <span>NewChan</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func NewChan(dir ChanDir, elem Type) *Chan</pre> <p>NewChan returns a new channel type for the given direction and element type. </p>
+<h3 id="Chan.Dir">func (*Chan) <span>Dir</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (c *Chan) Dir() ChanDir</pre> <p>Dir returns the direction of channel c. </p>
+<h3 id="Chan.Elem">func (*Chan) <span>Elem</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (c *Chan) Elem() Type</pre> <p>Elem returns the element type of channel c. </p>
+<h3 id="Chan.String">func (*Chan) <span>String</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (c *Chan) String() string</pre> <h3 id="Chan.Underlying">func (*Chan) <span>Underlying</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (c *Chan) Underlying() Type</pre> <h2 id="ChanDir">type <span>ChanDir</span> <span title="Added in Go 1.5">1.5</span> </h2> <p>A ChanDir value indicates a channel direction. </p>
+<pre data-language="go">type ChanDir int</pre> <p>The direction of a channel is indicated by one of these constants. </p>
+<pre data-language="go">const (
+ SendRecv ChanDir = iota
+ SendOnly
+ RecvOnly
+)</pre> <h2 id="Checker">type <span>Checker</span> <span title="Added in Go 1.5">1.5</span> </h2> <p>A Checker maintains the state of the type checker. It must be created with <a href="#NewChecker">NewChecker</a>. </p>
+<pre data-language="go">type Checker struct {
+ *Info
+ // contains filtered or unexported fields
+}
+</pre> <h3 id="NewChecker">func <span>NewChecker</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func NewChecker(conf *Config, fset *token.FileSet, pkg *Package, info *Info) *Checker</pre> <p>NewChecker returns a new <a href="#Checker">Checker</a> instance for a given package. <a href="#Package">Package</a> files may be added incrementally via checker.Files. </p>
+<h3 id="Checker.Files">func (*Checker) <span>Files</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (check *Checker) Files(files []*ast.File) error</pre> <p>Files checks the provided files as part of the checker's package. </p>
+<h2 id="Config">type <span>Config</span> <span title="Added in Go 1.5">1.5</span> </h2> <p>A Config specifies the configuration for type checking. The zero value for Config is a ready-to-use default configuration. </p>
+<pre data-language="go">type Config struct {
+ // Context is the context used for resolving global identifiers. If nil, the
+ // type checker will initialize this field with a newly created context.
+ Context *Context // Go 1.18
+
+ // GoVersion describes the accepted Go language version. The string must
+ // start with a prefix of the form "go%d.%d" (e.g. "go1.20", "go1.21rc1", or
+ // "go1.21.0") or it must be empty; an empty string disables Go language
+ // version checks. If the format is invalid, invoking the type checker will
+ // result in an error.
+ GoVersion string // Go 1.18
+
+ // If IgnoreFuncBodies is set, function bodies are not
+ // type-checked.
+ IgnoreFuncBodies bool
+
+ // If FakeImportC is set, `import "C"` (for packages requiring Cgo)
+ // declares an empty "C" package and errors are omitted for qualified
+ // identifiers referring to package C (which won't find an object).
+ // This feature is intended for the standard library cmd/api tool.
+ //
+ // Caution: Effects may be unpredictable due to follow-on errors.
+ // Do not use casually!
+ FakeImportC bool
+
+ // If Error != nil, it is called with each error found
+ // during type checking; err has dynamic type Error.
+ // Secondary errors (for instance, to enumerate all types
+ // involved in an invalid recursive type declaration) have
+ // error strings that start with a '\t' character.
+ // If Error == nil, type-checking stops with the first
+ // error found.
+ Error func(err error)
+
+ // An importer is used to import packages referred to from
+ // import declarations.
+ // If the installed importer implements ImporterFrom, the type
+ // checker calls ImportFrom instead of Import.
+ // The type checker reports an error if an importer is needed
+ // but none was installed.
+ Importer Importer
+
+ // If Sizes != nil, it provides the sizing functions for package unsafe.
+ // Otherwise SizesFor("gc", "amd64") is used instead.
+ Sizes Sizes
+
+ // If DisableUnusedImportCheck is set, packages are not checked
+ // for unused imports.
+ DisableUnusedImportCheck bool
+ // contains filtered or unexported fields
+}
+</pre> <h3 id="Config.Check">func (*Config) <span>Check</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (conf *Config) Check(path string, fset *token.FileSet, files []*ast.File, info *Info) (*Package, error)</pre> <p>Check type-checks a package and returns the resulting package object and the first error if any. Additionally, if info != nil, Check populates each of the non-nil maps in the <a href="#Info">Info</a> struct. </p>
+<p>The package is marked as complete if no errors occurred, otherwise it is incomplete. See [Config.Error] for controlling behavior in the presence of errors. </p>
+<p>The package is specified by a list of *ast.Files and corresponding file set, and the package path the package is identified with. The clean path must not be empty or dot ("."). </p>
+<h2 id="Const">type <span>Const</span> <span title="Added in Go 1.5">1.5</span> </h2> <p>A Const represents a declared constant. </p>
+<pre data-language="go">type Const struct {
+ // contains filtered or unexported fields
+}
+</pre> <h3 id="NewConst">func <span>NewConst</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func NewConst(pos token.Pos, pkg *Package, name string, typ Type, val constant.Value) *Const</pre> <p>NewConst returns a new constant with value val. The remaining arguments set the attributes found with all Objects. </p>
+<h3 id="Const.Exported">func (*Const) <span>Exported</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (obj *Const) Exported() bool</pre> <p>Exported reports whether the object is exported (starts with a capital letter). It doesn't take into account whether the object is in a local (function) scope or not. </p>
+<h3 id="Const.Id">func (*Const) <span>Id</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (obj *Const) Id() string</pre> <p>Id is a wrapper for Id(obj.Pkg(), obj.Name()). </p>
+<h3 id="Const.Name">func (*Const) <span>Name</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (obj *Const) Name() string</pre> <p>Name returns the object's (package-local, unqualified) name. </p>
+<h3 id="Const.Parent">func (*Const) <span>Parent</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (obj *Const) Parent() *Scope</pre> <p>Parent returns the scope in which the object is declared. The result is nil for methods and struct fields. </p>
+<h3 id="Const.Pkg">func (*Const) <span>Pkg</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (obj *Const) Pkg() *Package</pre> <p>Pkg returns the package to which the object belongs. The result is nil for labels and objects in the Universe scope. </p>
+<h3 id="Const.Pos">func (*Const) <span>Pos</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (obj *Const) Pos() token.Pos</pre> <p>Pos returns the declaration position of the object's identifier. </p>
+<h3 id="Const.String">func (*Const) <span>String</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (obj *Const) String() string</pre> <h3 id="Const.Type">func (*Const) <span>Type</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (obj *Const) Type() Type</pre> <p>Type returns the object's type. </p>
+<h3 id="Const.Val">func (*Const) <span>Val</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (obj *Const) Val() constant.Value</pre> <p>Val returns the constant's value. </p>
+<h2 id="Context">type <span>Context</span> <span title="Added in Go 1.18">1.18</span> </h2> <p>A Context is an opaque type checking context. It may be used to share identical type instances across type-checked packages or calls to Instantiate. Contexts are safe for concurrent use. </p>
+<p>The use of a shared context does not guarantee that identical instances are deduplicated in all cases. </p>
+<pre data-language="go">type Context struct {
+ // contains filtered or unexported fields
+}
+</pre> <h3 id="NewContext">func <span>NewContext</span> <span title="Added in Go 1.18">1.18</span> </h3> <pre data-language="go">func NewContext() *Context</pre> <p>NewContext creates a new Context. </p>
+<h2 id="Error">type <span>Error</span> <span title="Added in Go 1.5">1.5</span> </h2> <p>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. </p>
+<pre data-language="go">type Error struct {
+ Fset *token.FileSet // file set for interpretation of Pos
+ Pos token.Pos // error position
+ Msg string // error message
+ Soft bool // if set, error is "soft"
+ // contains filtered or unexported fields
+}
+</pre> <h3 id="Error.Error">func (Error) <span>Error</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (err Error) Error() string</pre> <p>Error returns an error string formatted as follows: filename:line:column: message </p>
+<h2 id="Func">type <span>Func</span> <span title="Added in Go 1.5">1.5</span> </h2> <p>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. </p>
+<pre data-language="go">type Func struct {
+ // contains filtered or unexported fields
+}
+</pre> <h3 id="MissingMethod">func <span>MissingMethod</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func MissingMethod(V Type, T *Interface, static bool) (method *Func, wrongType bool)</pre> <p>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: either a pointer receiver or wrong signature. </p>
+<p>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). </p>
+<h3 id="NewFunc">func <span>NewFunc</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func NewFunc(pos token.Pos, pkg *Package, name string, sig *Signature) *Func</pre> <p>NewFunc returns a new function with the given signature, representing the function's type. </p>
+<h3 id="Func.Exported">func (*Func) <span>Exported</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (obj *Func) Exported() bool</pre> <p>Exported reports whether the object is exported (starts with a capital letter). It doesn't take into account whether the object is in a local (function) scope or not. </p>
+<h3 id="Func.FullName">func (*Func) <span>FullName</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (obj *Func) FullName() string</pre> <p>FullName returns the package- or receiver-type-qualified name of function or method obj. </p>
+<h3 id="Func.Id">func (*Func) <span>Id</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (obj *Func) Id() string</pre> <p>Id is a wrapper for Id(obj.Pkg(), obj.Name()). </p>
+<h3 id="Func.Name">func (*Func) <span>Name</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (obj *Func) Name() string</pre> <p>Name returns the object's (package-local, unqualified) name. </p>
+<h3 id="Func.Origin">func (*Func) <span>Origin</span> <span title="Added in Go 1.19">1.19</span> </h3> <pre data-language="go">func (obj *Func) Origin() *Func</pre> <p>Origin returns the canonical Func for its receiver, i.e. the Func object recorded in Info.Defs. </p>
+<p>For synthetic functions created during instantiation (such as methods on an instantiated Named type or interface methods that depend on type arguments), this will be the corresponding Func on the generic (uninstantiated) type. For all other Funcs Origin returns the receiver. </p>
+<h3 id="Func.Parent">func (*Func) <span>Parent</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (obj *Func) Parent() *Scope</pre> <p>Parent returns the scope in which the object is declared. The result is nil for methods and struct fields. </p>
+<h3 id="Func.Pkg">func (*Func) <span>Pkg</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (obj *Func) Pkg() *Package</pre> <p>Pkg returns the package to which the function belongs. </p>
+<p>The result is nil for methods of types in the Universe scope, like method Error of the error built-in interface type. </p>
+<h3 id="Func.Pos">func (*Func) <span>Pos</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (obj *Func) Pos() token.Pos</pre> <p>Pos returns the declaration position of the object's identifier. </p>
+<h3 id="Func.Scope">func (*Func) <span>Scope</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (obj *Func) Scope() *Scope</pre> <p>Scope returns the scope of the function's body block. The result is nil for imported or instantiated functions and methods (but there is also no mechanism to get to an instantiated function). </p>
+<h3 id="Func.String">func (*Func) <span>String</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (obj *Func) String() string</pre> <h3 id="Func.Type">func (*Func) <span>Type</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (obj *Func) Type() Type</pre> <p>Type returns the object's type. </p>
+<h2 id="ImportMode">type <span>ImportMode</span> <span title="Added in Go 1.6">1.6</span> </h2> <p>ImportMode is reserved for future use. </p>
+<pre data-language="go">type ImportMode int</pre> <h2 id="Importer">type <span>Importer</span> <span title="Added in Go 1.5">1.5</span> </h2> <p>An Importer resolves import paths to Packages. </p>
+<p>CAUTION: This interface does not support the import of locally vendored packages. See <a href="https://golang.org/s/go15vendor">https://golang.org/s/go15vendor</a>. If possible, external implementations should implement <a href="#ImporterFrom">ImporterFrom</a>. </p>
+<pre data-language="go">type Importer interface {
+ // Import returns the imported package for the given import path.
+ // The semantics is like for ImporterFrom.ImportFrom except that
+ // dir and mode are ignored (since they are not present).
+ Import(path string) (*Package, error)
+}</pre> <h2 id="ImporterFrom">type <span>ImporterFrom</span> <span title="Added in Go 1.6">1.6</span> </h2> <p>An ImporterFrom resolves import paths to packages; it supports vendoring per <a href="https://golang.org/s/go15vendor">https://golang.org/s/go15vendor</a>. Use go/importer to obtain an ImporterFrom implementation. </p>
+<pre data-language="go">type ImporterFrom interface {
+ // Importer is present for backward-compatibility. Calling
+ // Import(path) is the same as calling ImportFrom(path, "", 0);
+ // i.e., locally vendored packages may not be found.
+ // The types package does not call Import if an ImporterFrom
+ // is present.
+ Importer
+
+ // ImportFrom returns the imported package for the given import
+ // path when imported by a package file located in dir.
+ // If the import failed, besides returning an error, ImportFrom
+ // is encouraged to cache and return a package anyway, if one
+ // was created. This will reduce package inconsistencies and
+ // follow-on type checker errors due to the missing package.
+ // The mode value must be 0; it is reserved for future use.
+ // Two calls to ImportFrom with the same path and dir must
+ // return the same package.
+ ImportFrom(path, dir string, mode ImportMode) (*Package, error)
+}</pre> <h2 id="Info">type <span>Info</span> <span title="Added in Go 1.5">1.5</span> </h2> <p>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. </p>
+<pre data-language="go">type Info struct {
+ // Types maps expressions to their types, and for constant
+ // expressions, also their values. Invalid expressions are
+ // omitted.
+ //
+ // For (possibly parenthesized) identifiers denoting built-in
+ // functions, the recorded signatures are call-site specific:
+ // if the call result is not a constant, the recorded type is
+ // an argument-specific signature. Otherwise, the recorded type
+ // is invalid.
+ //
+ // The Types map does not record the type of every identifier,
+ // only those that appear where an arbitrary expression is
+ // permitted. For instance, the identifier f in a selector
+ // expression x.f is found only in the Selections map, the
+ // identifier z in a variable declaration 'var z int' is found
+ // only in the Defs map, and identifiers denoting packages in
+ // qualified identifiers are collected in the Uses map.
+ Types map[ast.Expr]TypeAndValue
+
+ // Instances maps identifiers denoting generic types or functions to their
+ // type arguments and instantiated type.
+ //
+ // For example, Instances will map the identifier for 'T' in the type
+ // instantiation T[int, string] to the type arguments [int, string] and
+ // resulting instantiated *Named type. Given a generic function
+ // func F[A any](A), Instances will map the identifier for 'F' in the call
+ // expression F(int(1)) to the inferred type arguments [int], and resulting
+ // instantiated *Signature.
+ //
+ // Invariant: Instantiating Uses[id].Type() with Instances[id].TypeArgs
+ // results in an equivalent of Instances[id].Type.
+ Instances map[*ast.Ident]Instance // Go 1.18
+
+ // Defs maps identifiers to the objects they define (including
+ // package names, dots "." of dot-imports, and blank "_" identifiers).
+ // For identifiers that do not denote objects (e.g., the package name
+ // in package clauses, or symbolic variables t in t := x.(type) of
+ // type switch headers), the corresponding objects are nil.
+ //
+ // For an embedded field, Defs returns the field *Var it defines.
+ //
+ // Invariant: Defs[id] == nil || Defs[id].Pos() == id.Pos()
+ Defs map[*ast.Ident]Object
+
+ // Uses maps identifiers to the objects they denote.
+ //
+ // For an embedded field, Uses returns the *TypeName it denotes.
+ //
+ // Invariant: Uses[id].Pos() != id.Pos()
+ Uses map[*ast.Ident]Object
+
+ // Implicits maps nodes to their implicitly declared objects, if any.
+ // The following node and object types may appear:
+ //
+ // node declared object
+ //
+ // *ast.ImportSpec *PkgName for imports without renames
+ // *ast.CaseClause type-specific *Var for each type switch case clause (incl. default)
+ // *ast.Field anonymous parameter *Var (incl. unnamed results)
+ //
+ Implicits map[ast.Node]Object
+
+ // Selections maps selector expressions (excluding qualified identifiers)
+ // to their corresponding selections.
+ Selections map[*ast.SelectorExpr]*Selection
+
+ // Scopes maps ast.Nodes to the scopes they define. Package scopes are not
+ // associated with a specific node but with all files belonging to a package.
+ // Thus, the package scope can be found in the type-checked Package object.
+ // Scopes nest, with the Universe scope being the outermost scope, enclosing
+ // the package scope, which contains (one or more) files scopes, which enclose
+ // function scopes which in turn enclose statement and function literal scopes.
+ // Note that even though package-level functions are declared in the package
+ // scope, the function scopes are embedded in the file scope of the file
+ // containing the function declaration.
+ //
+ // The Scope of a function contains the declarations of any
+ // type parameters, parameters, and named results, plus any
+ // local declarations in the body block.
+ // It is coextensive with the complete extent of the
+ // function's syntax ([*ast.FuncDecl] or [*ast.FuncLit]).
+ // The Scopes mapping does not contain an entry for the
+ // function body ([*ast.BlockStmt]); the function's scope is
+ // associated with the [*ast.FuncType].
+ //
+ // The following node types may appear in Scopes:
+ //
+ // *ast.File
+ // *ast.FuncType
+ // *ast.TypeSpec
+ // *ast.BlockStmt
+ // *ast.IfStmt
+ // *ast.SwitchStmt
+ // *ast.TypeSwitchStmt
+ // *ast.CaseClause
+ // *ast.CommClause
+ // *ast.ForStmt
+ // *ast.RangeStmt
+ //
+ Scopes map[ast.Node]*Scope
+
+ // InitOrder is the list of package-level initializers in the order in which
+ // they must be executed. Initializers referring to variables related by an
+ // initialization dependency appear in topological order, the others appear
+ // in source order. Variables without an initialization expression do not
+ // appear in this list.
+ InitOrder []*Initializer
+
+ // FileVersions maps a file to its Go version string.
+ // If the file doesn't specify a version, the reported
+ // string is Config.GoVersion.
+ // Version strings begin with “go”, like “go1.21”, and
+ // are suitable for use with the [go/version] package.
+ FileVersions map[*ast.File]string // Go 1.22
+}
+</pre> <h4 id="example_Info"> <span class="text">Example</span>
+</h4> <p>ExampleInfo prints various facts recorded by the type checker in a types.Info struct: definitions of and references to each named object, and the type, value, and mode of every expression in the package. </p> <p>Code:</p> <pre class="code" data-language="go">// Parse a single source file.
+const input = `
+package fib
+
+type S string
+
+var a, b, c = len(b), S(c), "hello"
+
+func fib(x int) int {
+ if x &lt; 2 {
+ return x
+ }
+ return fib(x-1) - fib(x-2)
+}`
+// We need a specific fileset in this test below for positions.
+// Cannot use typecheck helper.
+fset := token.NewFileSet()
+f := mustParse(fset, input)
+
+// Type-check the package.
+// We create an empty map for each kind of input
+// we're interested in, and Check populates them.
+info := types.Info{
+ Types: make(map[ast.Expr]types.TypeAndValue),
+ Defs: make(map[*ast.Ident]types.Object),
+ Uses: make(map[*ast.Ident]types.Object),
+}
+var conf types.Config
+pkg, err := conf.Check("fib", fset, []*ast.File{f}, &amp;info)
+if err != nil {
+ log.Fatal(err)
+}
+
+// Print package-level variables in initialization order.
+fmt.Printf("InitOrder: %v\n\n", info.InitOrder)
+
+// For each named object, print the line and
+// column of its definition and each of its uses.
+fmt.Println("Defs and Uses of each named object:")
+usesByObj := make(map[types.Object][]string)
+for id, obj := range info.Uses {
+ posn := fset.Position(id.Pos())
+ lineCol := fmt.Sprintf("%d:%d", posn.Line, posn.Column)
+ usesByObj[obj] = append(usesByObj[obj], lineCol)
+}
+var items []string
+for obj, uses := range usesByObj {
+ sort.Strings(uses)
+ item := fmt.Sprintf("%s:\n defined at %s\n used at %s",
+ types.ObjectString(obj, types.RelativeTo(pkg)),
+ fset.Position(obj.Pos()),
+ strings.Join(uses, ", "))
+ items = append(items, item)
+}
+sort.Strings(items) // sort by line:col, in effect
+fmt.Println(strings.Join(items, "\n"))
+fmt.Println()
+
+fmt.Println("Types and Values of each expression:")
+items = nil
+for expr, tv := range info.Types {
+ var buf strings.Builder
+ posn := fset.Position(expr.Pos())
+ tvstr := tv.Type.String()
+ if tv.Value != nil {
+ tvstr += " = " + tv.Value.String()
+ }
+ // line:col | expr | mode : type = value
+ fmt.Fprintf(&amp;buf, "%2d:%2d | %-19s | %-7s : %s",
+ posn.Line, posn.Column, exprString(fset, expr),
+ mode(tv), tvstr)
+ items = append(items, buf.String())
+}
+sort.Strings(items)
+fmt.Println(strings.Join(items, "\n"))
+
+</pre> <p>Output:</p> <pre class="output" data-language="go">InitOrder: [c = "hello" b = S(c) a = len(b)]
+
+Defs and Uses of each named object:
+builtin len:
+ defined at -
+ used at 6:15
+func fib(x int) int:
+ defined at fib:8:6
+ used at 12:20, 12:9
+type S string:
+ defined at fib:4:6
+ used at 6:23
+type int:
+ defined at -
+ used at 8:12, 8:17
+type string:
+ defined at -
+ used at 4:8
+var b S:
+ defined at fib:6:8
+ used at 6:19
+var c string:
+ defined at fib:6:11
+ used at 6:25
+var x int:
+ defined at fib:8:10
+ used at 10:10, 12:13, 12:24, 9:5
+
+Types and Values of each expression:
+ 4: 8 | string | type : string
+ 6:15 | len | builtin : func(fib.S) int
+ 6:15 | len(b) | value : int
+ 6:19 | b | var : fib.S
+ 6:23 | S | type : fib.S
+ 6:23 | S(c) | value : fib.S
+ 6:25 | c | var : string
+ 6:29 | "hello" | value : string = "hello"
+ 8:12 | int | type : int
+ 8:17 | int | type : int
+ 9: 5 | x | var : int
+ 9: 5 | x &lt; 2 | value : untyped bool
+ 9: 9 | 2 | value : int = 2
+10:10 | x | var : int
+12: 9 | fib | value : func(x int) int
+12: 9 | fib(x - 1) | value : int
+12: 9 | fib(x-1) - fib(x-2) | value : int
+12:13 | x | var : int
+12:13 | x - 1 | value : int
+12:15 | 1 | value : int = 1
+12:20 | fib | value : func(x int) int
+12:20 | fib(x - 2) | value : int
+12:24 | x | var : int
+12:24 | x - 2 | value : int
+12:26 | 2 | value : int = 2
+</pre> <h3 id="Info.ObjectOf">func (*Info) <span>ObjectOf</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (info *Info) ObjectOf(id *ast.Ident) Object</pre> <p>ObjectOf returns the object denoted by the specified id, or nil if not found. </p>
+<p>If id is an embedded struct field, <a href="#Info.ObjectOf">Info.ObjectOf</a> returns the field (*<a href="#Var">Var</a>) it defines, not the type (*<a href="#TypeName">TypeName</a>) it uses. </p>
+<p>Precondition: the Uses and Defs maps are populated. </p>
+<h3 id="Info.PkgNameOf">func (*Info) <span>PkgNameOf</span> <span title="Added in Go 1.22">1.22</span> </h3> <pre data-language="go">func (info *Info) PkgNameOf(imp *ast.ImportSpec) *PkgName</pre> <p>PkgNameOf returns the local package name defined by the import, or nil if not found. </p>
+<p>For dot-imports, the package name is ".". </p>
+<p>Precondition: the Defs and Implicts maps are populated. </p>
+<h3 id="Info.TypeOf">func (*Info) <span>TypeOf</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (info *Info) TypeOf(e ast.Expr) Type</pre> <p>TypeOf returns the type of expression e, or nil if not found. Precondition: the Types, Uses and Defs maps are populated. </p>
+<h2 id="Initializer">type <span>Initializer</span> <span title="Added in Go 1.5">1.5</span> </h2> <p>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. </p>
+<pre data-language="go">type Initializer struct {
+ Lhs []*Var // var Lhs = Rhs
+ Rhs ast.Expr
+}
+</pre> <h3 id="Initializer.String">func (*Initializer) <span>String</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (init *Initializer) String() string</pre> <h2 id="Instance">type <span>Instance</span> <span title="Added in Go 1.18">1.18</span> </h2> <p>Instance reports the type arguments and instantiated type for type and function instantiations. For type instantiations, <a href="#Type">Type</a> will be of dynamic type *<a href="#Named">Named</a>. For function instantiations, <a href="#Type">Type</a> will be of dynamic type *Signature. </p>
+<pre data-language="go">type Instance struct {
+ TypeArgs *TypeList
+ Type Type
+}
+</pre> <h2 id="Interface">type <span>Interface</span> <span title="Added in Go 1.5">1.5</span> </h2> <p>An Interface represents an interface type. </p>
+<pre data-language="go">type Interface struct {
+ // contains filtered or unexported fields
+}
+</pre> <h3 id="NewInterface">func <span>NewInterface</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func NewInterface(methods []*Func, embeddeds []*Named) *Interface</pre> <p>NewInterface returns a new interface for the given methods and embedded types. NewInterface takes ownership of the provided methods and may modify their types by setting missing receivers. </p>
+<p>Deprecated: Use NewInterfaceType instead which allows arbitrary embedded types. </p>
+<h3 id="NewInterfaceType">func <span>NewInterfaceType</span> <span title="Added in Go 1.11">1.11</span> </h3> <pre data-language="go">func NewInterfaceType(methods []*Func, embeddeds []Type) *Interface</pre> <p>NewInterfaceType returns a new interface for the given methods and embedded types. NewInterfaceType takes ownership of the provided methods and may modify their types by setting missing receivers. </p>
+<p>To avoid race conditions, the interface's type set should be computed before concurrent use of the interface, by explicitly calling Complete. </p>
+<h3 id="Interface.Complete">func (*Interface) <span>Complete</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (t *Interface) Complete() *Interface</pre> <p>Complete computes the interface's type set. It must be called by users of <a href="#NewInterfaceType">NewInterfaceType</a> and <a href="#NewInterface">NewInterface</a> after the interface's embedded types are fully defined and before using the interface type in any way other than to form other types. The interface must not contain duplicate methods or a panic occurs. Complete returns the receiver. </p>
+<p>Interface types that have been completed are safe for concurrent use. </p>
+<h3 id="Interface.Embedded">func (*Interface) <span>Embedded</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (t *Interface) Embedded(i int) *Named</pre> <p>Embedded returns the i'th embedded defined (*<a href="#Named">Named</a>) type of interface t for 0 &lt;= i &lt; t.NumEmbeddeds(). The result is nil if the i'th embedded type is not a defined type. </p>
+<p>Deprecated: Use <a href="#Interface.EmbeddedType">Interface.EmbeddedType</a> which is not restricted to defined (*<a href="#Named">Named</a>) types. </p>
+<h3 id="Interface.EmbeddedType">func (*Interface) <span>EmbeddedType</span> <span title="Added in Go 1.11">1.11</span> </h3> <pre data-language="go">func (t *Interface) EmbeddedType(i int) Type</pre> <p>EmbeddedType returns the i'th embedded type of interface t for 0 &lt;= i &lt; t.NumEmbeddeds(). </p>
+<h3 id="Interface.Empty">func (*Interface) <span>Empty</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (t *Interface) Empty() bool</pre> <p>Empty reports whether t is the empty interface. </p>
+<h3 id="Interface.ExplicitMethod">func (*Interface) <span>ExplicitMethod</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (t *Interface) ExplicitMethod(i int) *Func</pre> <p>ExplicitMethod returns the i'th explicitly declared method of interface t for 0 &lt;= i &lt; t.NumExplicitMethods(). The methods are ordered by their unique <a href="#Id">Id</a>. </p>
+<h3 id="Interface.IsComparable">func (*Interface) <span>IsComparable</span> <span title="Added in Go 1.18">1.18</span> </h3> <pre data-language="go">func (t *Interface) IsComparable() bool</pre> <p>IsComparable reports whether each type in interface t's type set is comparable. </p>
+<h3 id="Interface.IsImplicit">func (*Interface) <span>IsImplicit</span> <span title="Added in Go 1.18">1.18</span> </h3> <pre data-language="go">func (t *Interface) IsImplicit() bool</pre> <p>IsImplicit reports whether the interface t is a wrapper for a type set literal. </p>
+<h3 id="Interface.IsMethodSet">func (*Interface) <span>IsMethodSet</span> <span title="Added in Go 1.18">1.18</span> </h3> <pre data-language="go">func (t *Interface) IsMethodSet() bool</pre> <p>IsMethodSet reports whether the interface t is fully described by its method set. </p>
+<h3 id="Interface.MarkImplicit">func (*Interface) <span>MarkImplicit</span> <span title="Added in Go 1.18">1.18</span> </h3> <pre data-language="go">func (t *Interface) MarkImplicit()</pre> <p>MarkImplicit marks the interface t as implicit, meaning this interface corresponds to a constraint literal such as ~T or A|B without explicit interface embedding. MarkImplicit should be called before any concurrent use of implicit interfaces. </p>
+<h3 id="Interface.Method">func (*Interface) <span>Method</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (t *Interface) Method(i int) *Func</pre> <p>Method returns the i'th method of interface t for 0 &lt;= i &lt; t.NumMethods(). The methods are ordered by their unique Id. </p>
+<h3 id="Interface.NumEmbeddeds">func (*Interface) <span>NumEmbeddeds</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (t *Interface) NumEmbeddeds() int</pre> <p>NumEmbeddeds returns the number of embedded types in interface t. </p>
+<h3 id="Interface.NumExplicitMethods">func (*Interface) <span>NumExplicitMethods</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (t *Interface) NumExplicitMethods() int</pre> <p>NumExplicitMethods returns the number of explicitly declared methods of interface t. </p>
+<h3 id="Interface.NumMethods">func (*Interface) <span>NumMethods</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (t *Interface) NumMethods() int</pre> <p>NumMethods returns the total number of methods of interface t. </p>
+<h3 id="Interface.String">func (*Interface) <span>String</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (t *Interface) String() string</pre> <h3 id="Interface.Underlying">func (*Interface) <span>Underlying</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (t *Interface) Underlying() Type</pre> <h2 id="Label">type <span>Label</span> <span title="Added in Go 1.5">1.5</span> </h2> <p>A Label represents a declared label. Labels don't have a type. </p>
+<pre data-language="go">type Label struct {
+ // contains filtered or unexported fields
+}
+</pre> <h3 id="NewLabel">func <span>NewLabel</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func NewLabel(pos token.Pos, pkg *Package, name string) *Label</pre> <p>NewLabel returns a new label. </p>
+<h3 id="Label.Exported">func (*Label) <span>Exported</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (obj *Label) Exported() bool</pre> <p>Exported reports whether the object is exported (starts with a capital letter). It doesn't take into account whether the object is in a local (function) scope or not. </p>
+<h3 id="Label.Id">func (*Label) <span>Id</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (obj *Label) Id() string</pre> <p>Id is a wrapper for Id(obj.Pkg(), obj.Name()). </p>
+<h3 id="Label.Name">func (*Label) <span>Name</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (obj *Label) Name() string</pre> <p>Name returns the object's (package-local, unqualified) name. </p>
+<h3 id="Label.Parent">func (*Label) <span>Parent</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (obj *Label) Parent() *Scope</pre> <p>Parent returns the scope in which the object is declared. The result is nil for methods and struct fields. </p>
+<h3 id="Label.Pkg">func (*Label) <span>Pkg</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (obj *Label) Pkg() *Package</pre> <p>Pkg returns the package to which the object belongs. The result is nil for labels and objects in the Universe scope. </p>
+<h3 id="Label.Pos">func (*Label) <span>Pos</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (obj *Label) Pos() token.Pos</pre> <p>Pos returns the declaration position of the object's identifier. </p>
+<h3 id="Label.String">func (*Label) <span>String</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (obj *Label) String() string</pre> <h3 id="Label.Type">func (*Label) <span>Type</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (obj *Label) Type() Type</pre> <p>Type returns the object's type. </p>
+<h2 id="Map">type <span>Map</span> <span title="Added in Go 1.5">1.5</span> </h2> <p>A Map represents a map type. </p>
+<pre data-language="go">type Map struct {
+ // contains filtered or unexported fields
+}
+</pre> <h3 id="NewMap">func <span>NewMap</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func NewMap(key, elem Type) *Map</pre> <p>NewMap returns a new map for the given key and element types. </p>
+<h3 id="Map.Elem">func (*Map) <span>Elem</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (m *Map) Elem() Type</pre> <p>Elem returns the element type of map m. </p>
+<h3 id="Map.Key">func (*Map) <span>Key</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (m *Map) Key() Type</pre> <p>Key returns the key type of map m. </p>
+<h3 id="Map.String">func (*Map) <span>String</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (t *Map) String() string</pre> <h3 id="Map.Underlying">func (*Map) <span>Underlying</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (t *Map) Underlying() Type</pre> <h2 id="MethodSet">type <span>MethodSet</span> <span title="Added in Go 1.5">1.5</span> </h2> <p>A MethodSet is an ordered set of concrete or abstract (interface) methods; a method is a <a href="#MethodVal">MethodVal</a> selection, and they are ordered by ascending m.Obj().Id(). The zero value for a MethodSet is a ready-to-use empty method set. </p>
+<pre data-language="go">type MethodSet struct {
+ // contains filtered or unexported fields
+}
+</pre> <h4 id="example_MethodSet"> <span class="text">Example</span>
+</h4> <p>ExampleMethodSet prints the method sets of various types. </p> <p>Code:</p> <pre class="code" data-language="go">// Parse a single source file.
+const input = `
+package temperature
+import "fmt"
+type Celsius float64
+func (c Celsius) String() string { return fmt.Sprintf("%g°C", c) }
+func (c *Celsius) SetF(f float64) { *c = Celsius(f - 32 / 9 * 5) }
+
+type S struct { I; m int }
+type I interface { m() byte }
+`
+fset := token.NewFileSet()
+f, err := parser.ParseFile(fset, "celsius.go", input, 0)
+if err != nil {
+ log.Fatal(err)
+}
+
+// Type-check a package consisting of this file.
+// Type information for the imported packages
+// comes from $GOROOT/pkg/$GOOS_$GOOARCH/fmt.a.
+conf := types.Config{Importer: importer.Default()}
+pkg, err := conf.Check("temperature", fset, []*ast.File{f}, nil)
+if err != nil {
+ log.Fatal(err)
+}
+
+// Print the method sets of Celsius and *Celsius.
+celsius := pkg.Scope().Lookup("Celsius").Type()
+for _, t := range []types.Type{celsius, types.NewPointer(celsius)} {
+ fmt.Printf("Method set of %s:\n", t)
+ mset := types.NewMethodSet(t)
+ for i := 0; i &lt; mset.Len(); i++ {
+ fmt.Println(mset.At(i))
+ }
+ fmt.Println()
+}
+
+// Print the method set of S.
+styp := pkg.Scope().Lookup("S").Type()
+fmt.Printf("Method set of %s:\n", styp)
+fmt.Println(types.NewMethodSet(styp))
+
+</pre> <p>Output:</p> <pre class="output" data-language="go">Method set of temperature.Celsius:
+method (temperature.Celsius) String() string
+
+Method set of *temperature.Celsius:
+method (*temperature.Celsius) SetF(f float64)
+method (*temperature.Celsius) String() string
+
+Method set of temperature.S:
+MethodSet {}
+</pre> <h3 id="NewMethodSet">func <span>NewMethodSet</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func NewMethodSet(T Type) *MethodSet</pre> <p>NewMethodSet returns the method set for the given type T. It always returns a non-nil method set, even if it is empty. </p>
+<h3 id="MethodSet.At">func (*MethodSet) <span>At</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (s *MethodSet) At(i int) *Selection</pre> <p>At returns the i'th method in s for 0 &lt;= i &lt; s.Len(). </p>
+<h3 id="MethodSet.Len">func (*MethodSet) <span>Len</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (s *MethodSet) Len() int</pre> <p>Len returns the number of methods in s. </p>
+<h3 id="MethodSet.Lookup">func (*MethodSet) <span>Lookup</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (s *MethodSet) Lookup(pkg *Package, name string) *Selection</pre> <p>Lookup returns the method with matching package and name, or nil if not found. </p>
+<h3 id="MethodSet.String">func (*MethodSet) <span>String</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (s *MethodSet) String() string</pre> <h2 id="Named">type <span>Named</span> <span title="Added in Go 1.5">1.5</span> </h2> <p>A Named represents a named (defined) type. </p>
+<pre data-language="go">type Named struct {
+ // contains filtered or unexported fields
+}
+</pre> <h3 id="NewNamed">func <span>NewNamed</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func NewNamed(obj *TypeName, underlying Type, methods []*Func) *Named</pre> <p>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. </p>
+<h3 id="Named.AddMethod">func (*Named) <span>AddMethod</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (t *Named) AddMethod(m *Func)</pre> <p>AddMethod adds method m unless it is already in the method list. t must not have type arguments. </p>
+<h3 id="Named.Method">func (*Named) <span>Method</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (t *Named) Method(i int) *Func</pre> <p>Method returns the i'th method of named type t for 0 &lt;= i &lt; t.NumMethods(). </p>
+<p>For an ordinary or instantiated type t, the receiver base type of this method is the named type t. For an uninstantiated generic type t, each method receiver is instantiated with its receiver type parameters. </p>
+<h3 id="Named.NumMethods">func (*Named) <span>NumMethods</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (t *Named) NumMethods() int</pre> <p>NumMethods returns the number of explicit methods defined for t. </p>
+<h3 id="Named.Obj">func (*Named) <span>Obj</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (t *Named) Obj() *TypeName</pre> <p>Obj returns the type name for the declaration defining the named type t. For instantiated types, this is same as the type name of the origin type. </p>
+<h3 id="Named.Origin">func (*Named) <span>Origin</span> <span title="Added in Go 1.18">1.18</span> </h3> <pre data-language="go">func (t *Named) Origin() *Named</pre> <p>Origin returns the generic type from which the named type t is instantiated. If t is not an instantiated type, the result is t. </p>
+<h3 id="Named.SetTypeParams">func (*Named) <span>SetTypeParams</span> <span title="Added in Go 1.18">1.18</span> </h3> <pre data-language="go">func (t *Named) SetTypeParams(tparams []*TypeParam)</pre> <p>SetTypeParams sets the type parameters of the named type t. t must not have type arguments. </p>
+<h3 id="Named.SetUnderlying">func (*Named) <span>SetUnderlying</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (t *Named) SetUnderlying(underlying Type)</pre> <p>SetUnderlying sets the underlying type and marks t as complete. t must not have type arguments. </p>
+<h3 id="Named.String">func (*Named) <span>String</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (t *Named) String() string</pre> <h3 id="Named.TypeArgs">func (*Named) <span>TypeArgs</span> <span title="Added in Go 1.18">1.18</span> </h3> <pre data-language="go">func (t *Named) TypeArgs() *TypeList</pre> <p>TypeArgs returns the type arguments used to instantiate the named type t. </p>
+<h3 id="Named.TypeParams">func (*Named) <span>TypeParams</span> <span title="Added in Go 1.18">1.18</span> </h3> <pre data-language="go">func (t *Named) TypeParams() *TypeParamList</pre> <p>TypeParams returns the type parameters of the named type t, or nil. The result is non-nil for an (originally) generic type even if it is instantiated. </p>
+<h3 id="Named.Underlying">func (*Named) <span>Underlying</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (t *Named) Underlying() Type</pre> <p>TODO(gri) Investigate if Unalias can be moved to where underlying is set. </p>
+<h2 id="Nil">type <span>Nil</span> <span title="Added in Go 1.5">1.5</span> </h2> <p>Nil represents the predeclared value nil. </p>
+<pre data-language="go">type Nil struct {
+ // contains filtered or unexported fields
+}
+</pre> <h3 id="Nil.Exported">func (*Nil) <span>Exported</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (obj *Nil) Exported() bool</pre> <p>Exported reports whether the object is exported (starts with a capital letter). It doesn't take into account whether the object is in a local (function) scope or not. </p>
+<h3 id="Nil.Id">func (*Nil) <span>Id</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (obj *Nil) Id() string</pre> <p>Id is a wrapper for Id(obj.Pkg(), obj.Name()). </p>
+<h3 id="Nil.Name">func (*Nil) <span>Name</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (obj *Nil) Name() string</pre> <p>Name returns the object's (package-local, unqualified) name. </p>
+<h3 id="Nil.Parent">func (*Nil) <span>Parent</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (obj *Nil) Parent() *Scope</pre> <p>Parent returns the scope in which the object is declared. The result is nil for methods and struct fields. </p>
+<h3 id="Nil.Pkg">func (*Nil) <span>Pkg</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (obj *Nil) Pkg() *Package</pre> <p>Pkg returns the package to which the object belongs. The result is nil for labels and objects in the Universe scope. </p>
+<h3 id="Nil.Pos">func (*Nil) <span>Pos</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (obj *Nil) Pos() token.Pos</pre> <p>Pos returns the declaration position of the object's identifier. </p>
+<h3 id="Nil.String">func (*Nil) <span>String</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (obj *Nil) String() string</pre> <h3 id="Nil.Type">func (*Nil) <span>Type</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (obj *Nil) Type() Type</pre> <p>Type returns the object's type. </p>
+<h2 id="Object">type <span>Object</span> <span title="Added in Go 1.5">1.5</span> </h2> <p>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. </p>
+<pre data-language="go">type Object interface {
+ Parent() *Scope // scope in which this object is declared; nil for methods and struct fields
+ Pos() token.Pos // position of object identifier in declaration
+ Pkg() *Package // package to which this object belongs; nil for labels and objects in the Universe scope
+ Name() string // package local object name
+ Type() Type // object type
+ Exported() bool // reports whether the name starts with a capital letter
+ Id() string // object name if exported, qualified name if not exported (see func Id)
+
+ // String returns a human-readable string of the object.
+ String() string
+ // contains filtered or unexported methods
+}</pre> <h3 id="LookupFieldOrMethod">func <span>LookupFieldOrMethod</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func LookupFieldOrMethod(T Type, addressable bool, pkg *Package, name string) (obj Object, index []int, indirect bool)</pre> <p>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). T must not be nil. </p>
+<p>The last index entry is the field or method index in the (possibly embedded) type where the entry was found, either: </p>
+<ol> <li>the list of declared methods of a named type; or </li>
+<li>the list of all methods (method set) of an interface type; or </li>
+<li>the list of fields of a struct type. </li>
+</ol> <p>The earlier index entries are the indices of the embedded struct fields traversed to get to the found entry, starting at depth 0. </p>
+<p>If no entry is found, a nil object is returned. In this case, the returned index and indirect values have the following meaning: </p>
+<ul> <li><p>If index != nil, the index sequence points to an ambiguous entry (the same name appeared more than once at the same embedding level). </p></li>
+<li><p>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. </p></li>
+</ul> <h2 id="Package">type <span>Package</span> <span title="Added in Go 1.5">1.5</span> </h2> <p>A Package describes a Go package. </p>
+<pre data-language="go">type Package struct {
+ // contains filtered or unexported fields
+}
+</pre> <p>The Unsafe package is the package returned by an importer for the import path "unsafe". </p>
+<pre data-language="go">var Unsafe *Package</pre> <h3 id="NewPackage">func <span>NewPackage</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func NewPackage(path, name string) *Package</pre> <p>NewPackage returns a new Package for the given package path and name. The package is not complete and contains no explicit imports. </p>
+<h3 id="Package.Complete">func (*Package) <span>Complete</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (pkg *Package) Complete() bool</pre> <p>A package is complete if its scope contains (at least) all exported objects; otherwise it is incomplete. </p>
+<h3 id="Package.GoVersion">func (*Package) <span>GoVersion</span> <span title="Added in Go 1.21">1.21</span> </h3> <pre data-language="go">func (pkg *Package) GoVersion() string</pre> <p>GoVersion returns the minimum Go version required by this package. If the minimum version is unknown, GoVersion returns the empty string. Individual source files may specify a different minimum Go version, as reported in the <span>go/ast.File.GoVersion</span> field. </p>
+<h3 id="Package.Imports">func (*Package) <span>Imports</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (pkg *Package) Imports() []*Package</pre> <p>Imports returns the list of packages directly imported by pkg; the list is in source order. </p>
+<p>If pkg was loaded from export data, Imports includes packages that provide package-level objects referenced by pkg. This may be more or less than the set of packages directly imported by pkg's source code. </p>
+<p>If pkg uses cgo and the FakeImportC configuration option was enabled, the imports list may contain a fake "C" package. </p>
+<h3 id="Package.MarkComplete">func (*Package) <span>MarkComplete</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (pkg *Package) MarkComplete()</pre> <p>MarkComplete marks a package as complete. </p>
+<h3 id="Package.Name">func (*Package) <span>Name</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (pkg *Package) Name() string</pre> <p>Name returns the package name. </p>
+<h3 id="Package.Path">func (*Package) <span>Path</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (pkg *Package) Path() string</pre> <p>Path returns the package path. </p>
+<h3 id="Package.Scope">func (*Package) <span>Scope</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (pkg *Package) Scope() *Scope</pre> <p>Scope returns the (complete or incomplete) package scope holding the objects declared at package level (TypeNames, Consts, Vars, and Funcs). For a nil pkg receiver, Scope returns the Universe scope. </p>
+<h3 id="Package.SetImports">func (*Package) <span>SetImports</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (pkg *Package) SetImports(list []*Package)</pre> <p>SetImports sets the list of explicitly imported packages to list. It is the caller's responsibility to make sure list elements are unique. </p>
+<h3 id="Package.SetName">func (*Package) <span>SetName</span> <span title="Added in Go 1.6">1.6</span> </h3> <pre data-language="go">func (pkg *Package) SetName(name string)</pre> <p>SetName sets the package name. </p>
+<h3 id="Package.String">func (*Package) <span>String</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (pkg *Package) String() string</pre> <h2 id="PkgName">type <span>PkgName</span> <span title="Added in Go 1.5">1.5</span> </h2> <p>A PkgName represents an imported Go package. PkgNames don't have a type. </p>
+<pre data-language="go">type PkgName struct {
+ // contains filtered or unexported fields
+}
+</pre> <h3 id="NewPkgName">func <span>NewPkgName</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func NewPkgName(pos token.Pos, pkg *Package, name string, imported *Package) *PkgName</pre> <p>NewPkgName returns a new PkgName object representing an imported package. The remaining arguments set the attributes found with all Objects. </p>
+<h3 id="PkgName.Exported">func (*PkgName) <span>Exported</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (obj *PkgName) Exported() bool</pre> <p>Exported reports whether the object is exported (starts with a capital letter). It doesn't take into account whether the object is in a local (function) scope or not. </p>
+<h3 id="PkgName.Id">func (*PkgName) <span>Id</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (obj *PkgName) Id() string</pre> <p>Id is a wrapper for Id(obj.Pkg(), obj.Name()). </p>
+<h3 id="PkgName.Imported">func (*PkgName) <span>Imported</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (obj *PkgName) Imported() *Package</pre> <p>Imported returns the package that was imported. It is distinct from Pkg(), which is the package containing the import statement. </p>
+<h3 id="PkgName.Name">func (*PkgName) <span>Name</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (obj *PkgName) Name() string</pre> <p>Name returns the object's (package-local, unqualified) name. </p>
+<h3 id="PkgName.Parent">func (*PkgName) <span>Parent</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (obj *PkgName) Parent() *Scope</pre> <p>Parent returns the scope in which the object is declared. The result is nil for methods and struct fields. </p>
+<h3 id="PkgName.Pkg">func (*PkgName) <span>Pkg</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (obj *PkgName) Pkg() *Package</pre> <p>Pkg returns the package to which the object belongs. The result is nil for labels and objects in the Universe scope. </p>
+<h3 id="PkgName.Pos">func (*PkgName) <span>Pos</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (obj *PkgName) Pos() token.Pos</pre> <p>Pos returns the declaration position of the object's identifier. </p>
+<h3 id="PkgName.String">func (*PkgName) <span>String</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (obj *PkgName) String() string</pre> <h3 id="PkgName.Type">func (*PkgName) <span>Type</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (obj *PkgName) Type() Type</pre> <p>Type returns the object's type. </p>
+<h2 id="Pointer">type <span>Pointer</span> <span title="Added in Go 1.5">1.5</span> </h2> <p>A Pointer represents a pointer type. </p>
+<pre data-language="go">type Pointer struct {
+ // contains filtered or unexported fields
+}
+</pre> <h3 id="NewPointer">func <span>NewPointer</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func NewPointer(elem Type) *Pointer</pre> <p>NewPointer returns a new pointer type for the given element (base) type. </p>
+<h3 id="Pointer.Elem">func (*Pointer) <span>Elem</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (p *Pointer) Elem() Type</pre> <p>Elem returns the element type for the given pointer p. </p>
+<h3 id="Pointer.String">func (*Pointer) <span>String</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (p *Pointer) String() string</pre> <h3 id="Pointer.Underlying">func (*Pointer) <span>Underlying</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (p *Pointer) Underlying() Type</pre> <h2 id="Qualifier">type <span>Qualifier</span> <span title="Added in Go 1.5">1.5</span> </h2> <p>A Qualifier controls how named package-level objects are printed in calls to <a href="#TypeString">TypeString</a>, <a href="#ObjectString">ObjectString</a>, and <a href="#SelectionString">SelectionString</a>. </p>
+<p>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. </p>
+<p>Using a nil Qualifier is equivalent to using (*<a href="#Package">Package</a>).Path: the object is qualified by the import path, e.g., "encoding/json.Marshal". </p>
+<pre data-language="go">type Qualifier func(*Package) string</pre> <h3 id="RelativeTo">func <span>RelativeTo</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func RelativeTo(pkg *Package) Qualifier</pre> <p>RelativeTo returns a <a href="#Qualifier">Qualifier</a> that fully qualifies members of all packages other than pkg. </p>
+<h2 id="Scope">type <span>Scope</span> <span title="Added in Go 1.5">1.5</span> </h2> <p>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. </p>
+<pre data-language="go">type Scope struct {
+ // contains filtered or unexported fields
+}
+</pre> <p>The Universe scope contains all predeclared objects of Go. It is the outermost scope of any chain of nested scopes. </p>
+<pre data-language="go">var Universe *Scope</pre> <h4 id="example_Scope"> <span class="text">Example</span>
+</h4> <p>ExampleScope prints the tree of Scopes of a package created from a set of parsed files. </p> <p>Code:</p> <pre class="code" data-language="go">// Parse the source files for a package.
+fset := token.NewFileSet()
+var files []*ast.File
+for _, src := range []string{
+ `package main
+import "fmt"
+func main() {
+ freezing := FToC(-18)
+ fmt.Println(freezing, Boiling) }
+`,
+ `package main
+import "fmt"
+type Celsius float64
+func (c Celsius) String() string { return fmt.Sprintf("%g°C", c) }
+func FToC(f float64) Celsius { return Celsius(f - 32 / 9 * 5) }
+const Boiling Celsius = 100
+func Unused() { {}; {{ var x int; _ = x }} } // make sure empty block scopes get printed
+`,
+} {
+ files = append(files, mustParse(fset, src))
+}
+
+// Type-check a package consisting of these files.
+// Type information for the imported "fmt" package
+// comes from $GOROOT/pkg/$GOOS_$GOOARCH/fmt.a.
+conf := types.Config{Importer: importer.Default()}
+pkg, err := conf.Check("temperature", fset, files, nil)
+if err != nil {
+ log.Fatal(err)
+}
+
+// Print the tree of scopes.
+// For determinism, we redact addresses.
+var buf strings.Builder
+pkg.Scope().WriteTo(&amp;buf, 0, true)
+rx := regexp.MustCompile(` 0x[a-fA-F\d]*`)
+fmt.Println(rx.ReplaceAllString(buf.String(), ""))
+
+</pre> <p>Output:</p> <pre class="output" data-language="go">package "temperature" scope {
+. const temperature.Boiling temperature.Celsius
+. type temperature.Celsius float64
+. func temperature.FToC(f float64) temperature.Celsius
+. func temperature.Unused()
+. func temperature.main()
+. main scope {
+. . package fmt
+. . function scope {
+. . . var freezing temperature.Celsius
+. . }
+. }
+. main scope {
+. . package fmt
+. . function scope {
+. . . var c temperature.Celsius
+. . }
+. . function scope {
+. . . var f float64
+. . }
+. . function scope {
+. . . block scope {
+. . . }
+. . . block scope {
+. . . . block scope {
+. . . . . var x int
+. . . . }
+. . . }
+. . }
+. }
+}
+</pre> <h3 id="NewScope">func <span>NewScope</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func NewScope(parent *Scope, pos, end token.Pos, comment string) *Scope</pre> <p>NewScope returns a new, empty scope contained in the given parent scope, if any. The comment is for debugging only. </p>
+<h3 id="Scope.Child">func (*Scope) <span>Child</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (s *Scope) Child(i int) *Scope</pre> <p>Child returns the i'th child scope for 0 &lt;= i &lt; NumChildren(). </p>
+<h3 id="Scope.Contains">func (*Scope) <span>Contains</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (s *Scope) Contains(pos token.Pos) bool</pre> <p>Contains reports whether pos is within the scope's extent. The result is guaranteed to be valid only if the type-checked AST has complete position information. </p>
+<h3 id="Scope.End">func (*Scope) <span>End</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (s *Scope) End() token.Pos</pre> <h3 id="Scope.Innermost">func (*Scope) <span>Innermost</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (s *Scope) Innermost(pos token.Pos) *Scope</pre> <p>Innermost returns the innermost (child) scope containing pos. If pos is not within any scope, the result is nil. The result is also nil for the Universe scope. The result is guaranteed to be valid only if the type-checked AST has complete position information. </p>
+<h3 id="Scope.Insert">func (*Scope) <span>Insert</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (s *Scope) Insert(obj Object) Object</pre> <p>Insert attempts to insert an object obj into scope s. If s already contains an alternative object alt with the same name, Insert leaves s unchanged and returns alt. Otherwise it inserts obj, sets the object's parent scope if not already set, and returns nil. </p>
+<h3 id="Scope.Len">func (*Scope) <span>Len</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (s *Scope) Len() int</pre> <p>Len returns the number of scope elements. </p>
+<h3 id="Scope.Lookup">func (*Scope) <span>Lookup</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (s *Scope) Lookup(name string) Object</pre> <p>Lookup returns the object in scope s with the given name if such an object exists; otherwise the result is nil. </p>
+<h3 id="Scope.LookupParent">func (*Scope) <span>LookupParent</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (s *Scope) LookupParent(name string, pos token.Pos) (*Scope, Object)</pre> <p>LookupParent follows the parent chain of scopes starting with s until it finds a scope where Lookup(name) returns a non-nil object, and then returns that scope and object. If a valid position pos is provided, only objects that were declared at or before pos are considered. If no such scope and object exists, the result is (nil, nil). </p>
+<p>Note that obj.Parent() may be different from the returned scope if the object was inserted into the scope and already had a parent at that time (see Insert). This can only happen for dot-imported objects whose scope is the scope of the package that exported them. </p>
+<h3 id="Scope.Names">func (*Scope) <span>Names</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (s *Scope) Names() []string</pre> <p>Names returns the scope's element names in sorted order. </p>
+<h3 id="Scope.NumChildren">func (*Scope) <span>NumChildren</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (s *Scope) NumChildren() int</pre> <p>NumChildren returns the number of scopes nested in s. </p>
+<h3 id="Scope.Parent">func (*Scope) <span>Parent</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (s *Scope) Parent() *Scope</pre> <p>Parent returns the scope's containing (parent) scope. </p>
+<h3 id="Scope.Pos">func (*Scope) <span>Pos</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (s *Scope) Pos() token.Pos</pre> <p>Pos and End describe the scope's source code extent [pos, end). The results are guaranteed to be valid only if the type-checked AST has complete position information. The extent is undefined for Universe and package scopes. </p>
+<h3 id="Scope.String">func (*Scope) <span>String</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (s *Scope) String() string</pre> <p>String returns a string representation of the scope, for debugging. </p>
+<h3 id="Scope.WriteTo">func (*Scope) <span>WriteTo</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (s *Scope) WriteTo(w io.Writer, n int, recurse bool)</pre> <p>WriteTo writes a string representation of the scope to w, with the scope elements sorted by name. The level of indentation is controlled by n &gt;= 0, with n == 0 for no indentation. If recurse is set, it also writes nested (children) scopes. </p>
+<h2 id="Selection">type <span>Selection</span> <span title="Added in Go 1.5">1.5</span> </h2> <p>A Selection describes a selector expression x.f. For the declarations: </p>
+<pre data-language="go">type T struct{ x int; E }
+type E struct{}
+func (e E) m() {}
+var p *T
+</pre> <p>the following relations exist: </p>
+<pre data-language="go">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
+</pre> <pre data-language="go">type Selection struct {
+ // contains filtered or unexported fields
+}
+</pre> <h3 id="Selection.Index">func (*Selection) <span>Index</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (s *Selection) Index() []int</pre> <p>Index describes the path from x to f in x.f. The last index entry is the field or method index of the type declaring f; either: </p>
+<ol> <li>the list of declared methods of a named type; or </li>
+<li>the list of methods of an interface type; or </li>
+<li>the list of fields of a struct type. </li>
+</ol> <p>The earlier index entries are the indices of the embedded fields implicitly traversed to get from (the type of) x to f, starting at embedding depth 0. </p>
+<h3 id="Selection.Indirect">func (*Selection) <span>Indirect</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (s *Selection) Indirect() bool</pre> <p>Indirect reports whether any pointer indirection was required to get from x to f in x.f. </p>
+<p>Beware: Indirect spuriously returns true (Go issue #8353) for a MethodVal selection in which the receiver argument and parameter both have type *T so there is no indirection. Unfortunately, a fix is too risky. </p>
+<h3 id="Selection.Kind">func (*Selection) <span>Kind</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (s *Selection) Kind() SelectionKind</pre> <p>Kind returns the selection kind. </p>
+<h3 id="Selection.Obj">func (*Selection) <span>Obj</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (s *Selection) Obj() Object</pre> <p>Obj returns the object denoted by x.f; a *Var for a field selection, and a *Func in all other cases. </p>
+<h3 id="Selection.Recv">func (*Selection) <span>Recv</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (s *Selection) Recv() Type</pre> <p>Recv returns the type of x in x.f. </p>
+<h3 id="Selection.String">func (*Selection) <span>String</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (s *Selection) String() string</pre> <h3 id="Selection.Type">func (*Selection) <span>Type</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (s *Selection) Type() Type</pre> <p>Type returns the type of x.f, which may be different from the type of f. See Selection for more information. </p>
+<h2 id="SelectionKind">type <span>SelectionKind</span> <span title="Added in Go 1.5">1.5</span> </h2> <p>SelectionKind describes the kind of a selector expression x.f (excluding qualified identifiers). </p>
+<p>If x is a struct or *struct, a selector expression x.f may denote a sequence of selection operations x.a.b.c.f. The SelectionKind describes the kind of the final (explicit) operation; all the previous (implicit) operations are always field selections. Each element of Indices specifies an implicit field (a, b, c) by its index in the struct type of the field selection operand. </p>
+<p>For a FieldVal operation, the final selection refers to the field specified by Selection.Obj. </p>
+<p>For a MethodVal operation, the final selection refers to a method. If the "pointerness" of the method's declared receiver does not match that of the effective receiver after implicit field selection, then an &amp; or * operation is implicitly applied to the receiver variable or value. So, x.f denotes (&amp;x.a.b.c).f when f requires a pointer receiver but x.a.b.c is a non-pointer variable; and it denotes (*x.a.b.c).f when f requires a non-pointer receiver but x.a.b.c is a pointer value. </p>
+<p>All pointer indirections, whether due to implicit or explicit field selections or * operations inserted for "pointerness", panic if applied to a nil pointer, so a method call x.f() may panic even before the function call. </p>
+<p>By contrast, a MethodExpr operation T.f is essentially equivalent to a function literal of the form: </p>
+<pre data-language="go">func(x T, args) (results) { return x.f(args) }
+</pre> <p>Consequently, any implicit field selections and * operations inserted for "pointerness" are not evaluated until the function is called, so a T.f or (*T).f expression never panics. </p>
+<pre data-language="go">type SelectionKind int</pre> <pre data-language="go">const (
+ FieldVal SelectionKind = iota // x.f is a struct field selector
+ MethodVal // x.f is a method selector
+ MethodExpr // x.f is a method expression
+)</pre> <h2 id="Signature">type <span>Signature</span> <span title="Added in Go 1.5">1.5</span> </h2> <p>A Signature represents a (non-builtin) function or method type. The receiver is ignored when comparing signatures for identity. </p>
+<pre data-language="go">type Signature struct {
+ // contains filtered or unexported fields
+}
+</pre> <h3 id="NewSignature">func <span>NewSignature</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func NewSignature(recv *Var, params, results *Tuple, variadic bool) *Signature</pre> <p>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. </p>
+<p>Deprecated: Use <a href="#NewSignatureType">NewSignatureType</a> instead which allows for type parameters. </p>
+<h3 id="NewSignatureType">func <span>NewSignatureType</span> <span title="Added in Go 1.18">1.18</span> </h3> <pre data-language="go">func NewSignatureType(recv *Var, recvTypeParams, typeParams []*TypeParam, params, results *Tuple, variadic bool) *Signature</pre> <p>NewSignatureType creates a new function type for the given receiver, receiver type parameters, type parameters, parameters, and results. If variadic is set, params must hold at least one parameter and the last parameter's core type must be of unnamed slice or bytestring type. If recv is non-nil, typeParams must be empty. If recvTypeParams is non-empty, recv must be non-nil. </p>
+<h3 id="Signature.Params">func (*Signature) <span>Params</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (s *Signature) Params() *Tuple</pre> <p>Params returns the parameters of signature s, or nil. </p>
+<h3 id="Signature.Recv">func (*Signature) <span>Recv</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (s *Signature) Recv() *Var</pre> <p>Recv returns the receiver of signature s (if a method), or nil if a function. It is ignored when comparing signatures for identity. </p>
+<p>For an abstract method, Recv returns the enclosing interface either as a *<a href="#Named">Named</a> or an *<a href="#Interface">Interface</a>. Due to embedding, an interface may contain methods whose receiver type is a different interface. </p>
+<h3 id="Signature.RecvTypeParams">func (*Signature) <span>RecvTypeParams</span> <span title="Added in Go 1.18">1.18</span> </h3> <pre data-language="go">func (s *Signature) RecvTypeParams() *TypeParamList</pre> <p>RecvTypeParams returns the receiver type parameters of signature s, or nil. </p>
+<h3 id="Signature.Results">func (*Signature) <span>Results</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (s *Signature) Results() *Tuple</pre> <p>Results returns the results of signature s, or nil. </p>
+<h3 id="Signature.String">func (*Signature) <span>String</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (t *Signature) String() string</pre> <h3 id="Signature.TypeParams">func (*Signature) <span>TypeParams</span> <span title="Added in Go 1.18">1.18</span> </h3> <pre data-language="go">func (s *Signature) TypeParams() *TypeParamList</pre> <p>TypeParams returns the type parameters of signature s, or nil. </p>
+<h3 id="Signature.Underlying">func (*Signature) <span>Underlying</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (t *Signature) Underlying() Type</pre> <h3 id="Signature.Variadic">func (*Signature) <span>Variadic</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (s *Signature) Variadic() bool</pre> <p>Variadic reports whether the signature s is variadic. </p>
+<h2 id="Sizes">type <span>Sizes</span> <span title="Added in Go 1.5">1.5</span> </h2> <p>Sizes defines the sizing functions for package unsafe. </p>
+<pre data-language="go">type Sizes interface {
+ // Alignof returns the alignment of a variable of type T.
+ // Alignof must implement the alignment guarantees required by the spec.
+ // The result must be &gt;= 1.
+ Alignof(T Type) int64
+
+ // Offsetsof returns the offsets of the given struct fields, in bytes.
+ // Offsetsof must implement the offset guarantees required by the spec.
+ // A negative entry in the result indicates that the struct is too large.
+ Offsetsof(fields []*Var) []int64
+
+ // Sizeof returns the size of a variable of type T.
+ // Sizeof must implement the size guarantees required by the spec.
+ // A negative result indicates that T is too large.
+ Sizeof(T Type) int64
+}</pre> <h3 id="SizesFor">func <span>SizesFor</span> <span title="Added in Go 1.9">1.9</span> </h3> <pre data-language="go">func SizesFor(compiler, arch string) Sizes</pre> <p>SizesFor returns the Sizes used by a compiler for an architecture. The result is nil if a compiler/architecture pair is not known. </p>
+<p>Supported architectures for compiler "gc": "386", "amd64", "amd64p32", "arm", "arm64", "loong64", "mips", "mipsle", "mips64", "mips64le", "ppc64", "ppc64le", "riscv64", "s390x", "sparc64", "wasm". </p>
+<h2 id="Slice">type <span>Slice</span> <span title="Added in Go 1.5">1.5</span> </h2> <p>A Slice represents a slice type. </p>
+<pre data-language="go">type Slice struct {
+ // contains filtered or unexported fields
+}
+</pre> <h3 id="NewSlice">func <span>NewSlice</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func NewSlice(elem Type) *Slice</pre> <p>NewSlice returns a new slice type for the given element type. </p>
+<h3 id="Slice.Elem">func (*Slice) <span>Elem</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (s *Slice) Elem() Type</pre> <p>Elem returns the element type of slice s. </p>
+<h3 id="Slice.String">func (*Slice) <span>String</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (s *Slice) String() string</pre> <h3 id="Slice.Underlying">func (*Slice) <span>Underlying</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (s *Slice) Underlying() Type</pre> <h2 id="StdSizes">type <span>StdSizes</span> <span title="Added in Go 1.5">1.5</span> </h2> <p>StdSizes is a convenience type for creating commonly used Sizes. It makes the following simplifying assumptions: </p>
+<ul> <li>The size of explicitly sized basic types (int16, etc.) is the specified size. </li>
+<li>The size of strings and interfaces is 2*WordSize. </li>
+<li>The size of slices is 3*WordSize. </li>
+<li>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. </li>
+<li>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. </li>
+<li>All other types have size WordSize. </li>
+<li>Arrays and structs are aligned per spec definition; all other types are naturally aligned with a maximum alignment MaxAlign. </li>
+</ul> <p>*StdSizes implements Sizes. </p>
+<pre data-language="go">type StdSizes struct {
+ WordSize int64 // word size in bytes - must be &gt;= 4 (32bits)
+ MaxAlign int64 // maximum alignment in bytes - must be &gt;= 1
+}
+</pre> <h3 id="StdSizes.Alignof">func (*StdSizes) <span>Alignof</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (s *StdSizes) Alignof(T Type) (result int64)</pre> <h3 id="StdSizes.Offsetsof">func (*StdSizes) <span>Offsetsof</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (s *StdSizes) Offsetsof(fields []*Var) []int64</pre> <h3 id="StdSizes.Sizeof">func (*StdSizes) <span>Sizeof</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (s *StdSizes) Sizeof(T Type) int64</pre> <h2 id="Struct">type <span>Struct</span> <span title="Added in Go 1.5">1.5</span> </h2> <p>A Struct represents a struct type. </p>
+<pre data-language="go">type Struct struct {
+ // contains filtered or unexported fields
+}
+</pre> <h3 id="NewStruct">func <span>NewStruct</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func NewStruct(fields []*Var, tags []string) *Struct</pre> <p>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. </p>
+<h3 id="Struct.Field">func (*Struct) <span>Field</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (s *Struct) Field(i int) *Var</pre> <p>Field returns the i'th field for 0 &lt;= i &lt; NumFields(). </p>
+<h3 id="Struct.NumFields">func (*Struct) <span>NumFields</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (s *Struct) NumFields() int</pre> <p>NumFields returns the number of fields in the struct (including blank and embedded fields). </p>
+<h3 id="Struct.String">func (*Struct) <span>String</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (t *Struct) String() string</pre> <h3 id="Struct.Tag">func (*Struct) <span>Tag</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (s *Struct) Tag(i int) string</pre> <p>Tag returns the i'th field tag for 0 &lt;= i &lt; NumFields(). </p>
+<h3 id="Struct.Underlying">func (*Struct) <span>Underlying</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (t *Struct) Underlying() Type</pre> <h2 id="Term">type <span>Term</span> <span title="Added in Go 1.18">1.18</span> </h2> <p>A Term represents a term in a <a href="#Union">Union</a>. </p>
+<pre data-language="go">type Term term</pre> <h3 id="NewTerm">func <span>NewTerm</span> <span title="Added in Go 1.18">1.18</span> </h3> <pre data-language="go">func NewTerm(tilde bool, typ Type) *Term</pre> <p>NewTerm returns a new union term. </p>
+<h3 id="Term.String">func (*Term) <span>String</span> <span title="Added in Go 1.18">1.18</span> </h3> <pre data-language="go">func (t *Term) String() string</pre> <h3 id="Term.Tilde">func (*Term) <span>Tilde</span> <span title="Added in Go 1.18">1.18</span> </h3> <pre data-language="go">func (t *Term) Tilde() bool</pre> <h3 id="Term.Type">func (*Term) <span>Type</span> <span title="Added in Go 1.18">1.18</span> </h3> <pre data-language="go">func (t *Term) Type() Type</pre> <h2 id="Tuple">type <span>Tuple</span> <span title="Added in Go 1.5">1.5</span> </h2> <p>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. </p>
+<pre data-language="go">type Tuple struct {
+ // contains filtered or unexported fields
+}
+</pre> <h3 id="NewTuple">func <span>NewTuple</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func NewTuple(x ...*Var) *Tuple</pre> <p>NewTuple returns a new tuple for the given variables. </p>
+<h3 id="Tuple.At">func (*Tuple) <span>At</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (t *Tuple) At(i int) *Var</pre> <p>At returns the i'th variable of tuple t. </p>
+<h3 id="Tuple.Len">func (*Tuple) <span>Len</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (t *Tuple) Len() int</pre> <p>Len returns the number variables of tuple t. </p>
+<h3 id="Tuple.String">func (*Tuple) <span>String</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (t *Tuple) String() string</pre> <h3 id="Tuple.Underlying">func (*Tuple) <span>Underlying</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (t *Tuple) Underlying() Type</pre> <h2 id="Type">type <span>Type</span> <span title="Added in Go 1.5">1.5</span> </h2> <p>A Type represents a type of Go. All types implement the Type interface. </p>
+<pre data-language="go">type Type interface {
+ // Underlying returns the underlying type of a type.
+ Underlying() Type
+
+ // String returns a string representation of a type.
+ String() string
+}</pre> <h3 id="Default">func <span>Default</span> <span title="Added in Go 1.8">1.8</span> </h3> <pre data-language="go">func Default(t Type) Type</pre> <p>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. </p>
+<h3 id="Instantiate">func <span>Instantiate</span> <span title="Added in Go 1.18">1.18</span> </h3> <pre data-language="go">func Instantiate(ctxt *Context, orig Type, targs []Type, validate bool) (Type, error)</pre> <p>Instantiate instantiates the type orig with the given type arguments targs. orig must be a *Named or a *Signature type. If there is no error, the resulting Type is an instantiated type of the same kind (either a *Named or a *Signature). Methods attached to a *Named type are also instantiated, and associated with a new *Func that has the same position as the original method, but nil function scope. </p>
+<p>If ctxt is non-nil, it may be used to de-duplicate the instance against previous instances with the same identity. As a special case, generic *Signature origin types are only considered identical if they are pointer equivalent, so that instantiating distinct (but possibly identical) signatures will yield different instances. The use of a shared context does not guarantee that identical instances are deduplicated in all cases. </p>
+<p>If validate is set, Instantiate verifies that the number of type arguments and parameters match, and that the type arguments satisfy their corresponding type constraints. If verification fails, the resulting error may wrap an *ArgumentError indicating which type argument did not satisfy its corresponding type parameter constraint, and why. </p>
+<p>If validate is not set, Instantiate does not verify the type argument count or whether the type arguments satisfy their constraints. Instantiate is guaranteed to not return an error, but may panic. Specifically, for *Signature types, Instantiate will panic immediately if the type argument count is incorrect; for *Named types, a panic may occur later inside the *Named API. </p>
+<h3 id="Unalias">func <span>Unalias</span> <span title="Added in Go 1.22">1.22</span> </h3> <pre data-language="go">func Unalias(t Type) Type</pre> <p>Unalias returns t if it is not an alias type; otherwise it follows t's alias chain until it reaches a non-alias type which is then returned. Consequently, the result is never an alias type. </p>
+<h2 id="TypeAndValue">type <span>TypeAndValue</span> <span title="Added in Go 1.5">1.5</span> </h2> <p>TypeAndValue reports the type and value (for constants) of the corresponding expression. </p>
+<pre data-language="go">type TypeAndValue struct {
+ Type Type
+ Value constant.Value
+ // contains filtered or unexported fields
+}
+</pre> <h3 id="Eval">func <span>Eval</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func Eval(fset *token.FileSet, pkg *Package, pos token.Pos, expr string) (_ TypeAndValue, err error)</pre> <p>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. </p>
+<p>The meaning of the parameters fset, pkg, and pos is the same as in <a href="#CheckExpr">CheckExpr</a>. An error is returned if expr cannot be parsed successfully, or the resulting expr AST cannot be type-checked. </p>
+<h3 id="TypeAndValue.Addressable">func (TypeAndValue) <span>Addressable</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (tv TypeAndValue) Addressable() bool</pre> <p>Addressable reports whether the corresponding expression is addressable (<a href="https://golang.org/ref/spec#Address_operators">https://golang.org/ref/spec#Address_operators</a>). </p>
+<h3 id="TypeAndValue.Assignable">func (TypeAndValue) <span>Assignable</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (tv TypeAndValue) Assignable() bool</pre> <p>Assignable reports whether the corresponding expression is assignable to (provided a value of the right type). </p>
+<h3 id="TypeAndValue.HasOk">func (TypeAndValue) <span>HasOk</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (tv TypeAndValue) HasOk() bool</pre> <p>HasOk reports whether the corresponding expression may be used on the rhs of a comma-ok assignment. </p>
+<h3 id="TypeAndValue.IsBuiltin">func (TypeAndValue) <span>IsBuiltin</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (tv TypeAndValue) IsBuiltin() bool</pre> <p>IsBuiltin reports whether the corresponding expression denotes a (possibly parenthesized) built-in function. </p>
+<h3 id="TypeAndValue.IsNil">func (TypeAndValue) <span>IsNil</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (tv TypeAndValue) IsNil() bool</pre> <p>IsNil reports whether the corresponding expression denotes the predeclared value nil. </p>
+<h3 id="TypeAndValue.IsType">func (TypeAndValue) <span>IsType</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (tv TypeAndValue) IsType() bool</pre> <p>IsType reports whether the corresponding expression specifies a type. </p>
+<h3 id="TypeAndValue.IsValue">func (TypeAndValue) <span>IsValue</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (tv TypeAndValue) IsValue() bool</pre> <p>IsValue reports whether the corresponding expression is a value. Builtins are not considered values. Constant values have a non- nil Value. </p>
+<h3 id="TypeAndValue.IsVoid">func (TypeAndValue) <span>IsVoid</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (tv TypeAndValue) IsVoid() bool</pre> <p>IsVoid reports whether the corresponding expression is a function call without results. </p>
+<h2 id="TypeList">type <span>TypeList</span> <span title="Added in Go 1.18">1.18</span> </h2> <p>TypeList holds a list of types. </p>
+<pre data-language="go">type TypeList struct {
+ // contains filtered or unexported fields
+}
+</pre> <h3 id="TypeList.At">func (*TypeList) <span>At</span> <span title="Added in Go 1.18">1.18</span> </h3> <pre data-language="go">func (l *TypeList) At(i int) Type</pre> <p>At returns the i'th type in the list. </p>
+<h3 id="TypeList.Len">func (*TypeList) <span>Len</span> <span title="Added in Go 1.18">1.18</span> </h3> <pre data-language="go">func (l *TypeList) Len() int</pre> <p>Len returns the number of types in the list. It is safe to call on a nil receiver. </p>
+<h2 id="TypeName">type <span>TypeName</span> <span title="Added in Go 1.5">1.5</span> </h2> <p>A TypeName represents a name for a (defined or alias) type. </p>
+<pre data-language="go">type TypeName struct {
+ // contains filtered or unexported fields
+}
+</pre> <h3 id="NewTypeName">func <span>NewTypeName</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func NewTypeName(pos token.Pos, pkg *Package, name string, typ Type) *TypeName</pre> <p>NewTypeName returns a new type name denoting the given typ. The remaining arguments set the attributes found with all Objects. </p>
+<p>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. </p>
+<h3 id="TypeName.Exported">func (*TypeName) <span>Exported</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (obj *TypeName) Exported() bool</pre> <p>Exported reports whether the object is exported (starts with a capital letter). It doesn't take into account whether the object is in a local (function) scope or not. </p>
+<h3 id="TypeName.Id">func (*TypeName) <span>Id</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (obj *TypeName) Id() string</pre> <p>Id is a wrapper for Id(obj.Pkg(), obj.Name()). </p>
+<h3 id="TypeName.IsAlias">func (*TypeName) <span>IsAlias</span> <span title="Added in Go 1.9">1.9</span> </h3> <pre data-language="go">func (obj *TypeName) IsAlias() bool</pre> <p>IsAlias reports whether obj is an alias name for a type. </p>
+<h3 id="TypeName.Name">func (*TypeName) <span>Name</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (obj *TypeName) Name() string</pre> <p>Name returns the object's (package-local, unqualified) name. </p>
+<h3 id="TypeName.Parent">func (*TypeName) <span>Parent</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (obj *TypeName) Parent() *Scope</pre> <p>Parent returns the scope in which the object is declared. The result is nil for methods and struct fields. </p>
+<h3 id="TypeName.Pkg">func (*TypeName) <span>Pkg</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (obj *TypeName) Pkg() *Package</pre> <p>Pkg returns the package to which the object belongs. The result is nil for labels and objects in the Universe scope. </p>
+<h3 id="TypeName.Pos">func (*TypeName) <span>Pos</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (obj *TypeName) Pos() token.Pos</pre> <p>Pos returns the declaration position of the object's identifier. </p>
+<h3 id="TypeName.String">func (*TypeName) <span>String</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (obj *TypeName) String() string</pre> <h3 id="TypeName.Type">func (*TypeName) <span>Type</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (obj *TypeName) Type() Type</pre> <p>Type returns the object's type. </p>
+<h2 id="TypeParam">type <span>TypeParam</span> <span title="Added in Go 1.18">1.18</span> </h2> <p>A TypeParam represents a type parameter type. </p>
+<pre data-language="go">type TypeParam struct {
+ // contains filtered or unexported fields
+}
+</pre> <h3 id="NewTypeParam">func <span>NewTypeParam</span> <span title="Added in Go 1.18">1.18</span> </h3> <pre data-language="go">func NewTypeParam(obj *TypeName, constraint Type) *TypeParam</pre> <p>NewTypeParam returns a new TypeParam. Type parameters may be set on a Named or Signature type by calling SetTypeParams. Setting a type parameter on more than one type will result in a panic. </p>
+<p>The constraint argument can be nil, and set later via SetConstraint. If the constraint is non-nil, it must be fully defined. </p>
+<h3 id="TypeParam.Constraint">func (*TypeParam) <span>Constraint</span> <span title="Added in Go 1.18">1.18</span> </h3> <pre data-language="go">func (t *TypeParam) Constraint() Type</pre> <p>Constraint returns the type constraint specified for t. </p>
+<h3 id="TypeParam.Index">func (*TypeParam) <span>Index</span> <span title="Added in Go 1.18">1.18</span> </h3> <pre data-language="go">func (t *TypeParam) Index() int</pre> <p>Index returns the index of the type param within its param list, or -1 if the type parameter has not yet been bound to a type. </p>
+<h3 id="TypeParam.Obj">func (*TypeParam) <span>Obj</span> <span title="Added in Go 1.18">1.18</span> </h3> <pre data-language="go">func (t *TypeParam) Obj() *TypeName</pre> <p>Obj returns the type name for the type parameter t. </p>
+<h3 id="TypeParam.SetConstraint">func (*TypeParam) <span>SetConstraint</span> <span title="Added in Go 1.18">1.18</span> </h3> <pre data-language="go">func (t *TypeParam) SetConstraint(bound Type)</pre> <p>SetConstraint sets the type constraint for t. </p>
+<p>It must be called by users of NewTypeParam after the bound's underlying is fully defined, and before using the type parameter in any way other than to form other types. Once SetConstraint returns the receiver, t is safe for concurrent use. </p>
+<h3 id="TypeParam.String">func (*TypeParam) <span>String</span> <span title="Added in Go 1.18">1.18</span> </h3> <pre data-language="go">func (t *TypeParam) String() string</pre> <h3 id="TypeParam.Underlying">func (*TypeParam) <span>Underlying</span> <span title="Added in Go 1.18">1.18</span> </h3> <pre data-language="go">func (t *TypeParam) Underlying() Type</pre> <h2 id="TypeParamList">type <span>TypeParamList</span> <span title="Added in Go 1.18">1.18</span> </h2> <p>TypeParamList holds a list of type parameters. </p>
+<pre data-language="go">type TypeParamList struct {
+ // contains filtered or unexported fields
+}
+</pre> <h3 id="TypeParamList.At">func (*TypeParamList) <span>At</span> <span title="Added in Go 1.18">1.18</span> </h3> <pre data-language="go">func (l *TypeParamList) At(i int) *TypeParam</pre> <p>At returns the i'th type parameter in the list. </p>
+<h3 id="TypeParamList.Len">func (*TypeParamList) <span>Len</span> <span title="Added in Go 1.18">1.18</span> </h3> <pre data-language="go">func (l *TypeParamList) Len() int</pre> <p>Len returns the number of type parameters in the list. It is safe to call on a nil receiver. </p>
+<h2 id="Union">type <span>Union</span> <span title="Added in Go 1.18">1.18</span> </h2> <p>A Union represents a union of terms embedded in an interface. </p>
+<pre data-language="go">type Union struct {
+ // contains filtered or unexported fields
+}
+</pre> <h3 id="NewUnion">func <span>NewUnion</span> <span title="Added in Go 1.18">1.18</span> </h3> <pre data-language="go">func NewUnion(terms []*Term) *Union</pre> <p>NewUnion returns a new <a href="#Union">Union</a> type with the given terms. It is an error to create an empty union; they are syntactically not possible. </p>
+<h3 id="Union.Len">func (*Union) <span>Len</span> <span title="Added in Go 1.18">1.18</span> </h3> <pre data-language="go">func (u *Union) Len() int</pre> <h3 id="Union.String">func (*Union) <span>String</span> <span title="Added in Go 1.18">1.18</span> </h3> <pre data-language="go">func (u *Union) String() string</pre> <h3 id="Union.Term">func (*Union) <span>Term</span> <span title="Added in Go 1.18">1.18</span> </h3> <pre data-language="go">func (u *Union) Term(i int) *Term</pre> <h3 id="Union.Underlying">func (*Union) <span>Underlying</span> <span title="Added in Go 1.18">1.18</span> </h3> <pre data-language="go">func (u *Union) Underlying() Type</pre> <h2 id="Var">type <span>Var</span> <span title="Added in Go 1.5">1.5</span> </h2> <p>A Variable represents a declared variable (including function parameters and results, and struct fields). </p>
+<pre data-language="go">type Var struct {
+ // contains filtered or unexported fields
+}
+</pre> <h3 id="NewField">func <span>NewField</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func NewField(pos token.Pos, pkg *Package, name string, typ Type, embedded bool) *Var</pre> <p>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. </p>
+<h3 id="NewParam">func <span>NewParam</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func NewParam(pos token.Pos, pkg *Package, name string, typ Type) *Var</pre> <p>NewParam returns a new variable representing a function parameter. </p>
+<h3 id="NewVar">func <span>NewVar</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func NewVar(pos token.Pos, pkg *Package, name string, typ Type) *Var</pre> <p>NewVar returns a new variable. The arguments set the attributes found with all Objects. </p>
+<h3 id="Var.Anonymous">func (*Var) <span>Anonymous</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (obj *Var) Anonymous() bool</pre> <p>Anonymous reports whether the variable is an embedded field. Same as Embedded; only present for backward-compatibility. </p>
+<h3 id="Var.Embedded">func (*Var) <span>Embedded</span> <span title="Added in Go 1.11">1.11</span> </h3> <pre data-language="go">func (obj *Var) Embedded() bool</pre> <p>Embedded reports whether the variable is an embedded field. </p>
+<h3 id="Var.Exported">func (*Var) <span>Exported</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (obj *Var) Exported() bool</pre> <p>Exported reports whether the object is exported (starts with a capital letter). It doesn't take into account whether the object is in a local (function) scope or not. </p>
+<h3 id="Var.Id">func (*Var) <span>Id</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (obj *Var) Id() string</pre> <p>Id is a wrapper for Id(obj.Pkg(), obj.Name()). </p>
+<h3 id="Var.IsField">func (*Var) <span>IsField</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (obj *Var) IsField() bool</pre> <p>IsField reports whether the variable is a struct field. </p>
+<h3 id="Var.Name">func (*Var) <span>Name</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (obj *Var) Name() string</pre> <p>Name returns the object's (package-local, unqualified) name. </p>
+<h3 id="Var.Origin">func (*Var) <span>Origin</span> <span title="Added in Go 1.19">1.19</span> </h3> <pre data-language="go">func (obj *Var) Origin() *Var</pre> <p>Origin returns the canonical Var for its receiver, i.e. the Var object recorded in Info.Defs. </p>
+<p>For synthetic Vars created during instantiation (such as struct fields or function parameters that depend on type arguments), this will be the corresponding Var on the generic (uninstantiated) type. For all other Vars Origin returns the receiver. </p>
+<h3 id="Var.Parent">func (*Var) <span>Parent</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (obj *Var) Parent() *Scope</pre> <p>Parent returns the scope in which the object is declared. The result is nil for methods and struct fields. </p>
+<h3 id="Var.Pkg">func (*Var) <span>Pkg</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (obj *Var) Pkg() *Package</pre> <p>Pkg returns the package to which the object belongs. The result is nil for labels and objects in the Universe scope. </p>
+<h3 id="Var.Pos">func (*Var) <span>Pos</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (obj *Var) Pos() token.Pos</pre> <p>Pos returns the declaration position of the object's identifier. </p>
+<h3 id="Var.String">func (*Var) <span>String</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (obj *Var) String() string</pre> <h3 id="Var.Type">func (*Var) <span>Type</span> <span title="Added in Go 1.5">1.5</span> </h3> <pre data-language="go">func (obj *Var) Type() Type</pre> <p>Type returns the object's type. </p><div class="_attribution">
+ <p class="_attribution-p">
+ &copy; Google, Inc.<br>Licensed under the Creative Commons Attribution License 3.0.<br>
+ <a href="http://golang.org/pkg/go/types/" class="_attribution-link">http://golang.org/pkg/go/types/</a>
+ </p>
+</div>