package
0.31.0
Repository: https://go.googlesource.com/tools
Documentation: pkg.go.dev

# Functions

ErrorCodeStartEnd extracts additional information from types.Error values generated by Go version 1.16 and later: the error code, start position, and end position.
FileQualifier returns a [types.Qualifier] function that qualifies imported symbols appropriately based on the import environment of a given file.
ForEachElement calls f for type T and each type reachable from its type through reflection.
GetVarKind returns an invalid VarKind.
IsPackageLevel reports whether obj is a package-level symbol.
IsZeroExpr uses simple syntactic heuristics to report whether expr is a obvious zero value, such as 0, "", nil, or false.
NameRelativeTo returns a types.Qualifier that qualifies members of all packages other than pkg, using only the package name.
Origin returns the generic type of the Named or Alias type t if it is instantiated, otherwise it returns t.
ReceiverNamed returns the named type (if any) associated with the type of recv, which may be of the form N or *N, or aliases thereof.
No description provided by the author
SetVarKind has no effect.
TooNewStdSymbols computes the set of package-level symbols exported by pkg that are not available at the specified version.
TypeArgs is a light shim around t.TypeArgs().
TypeExpr returns syntax for the specified type.
TypeParams is a light shim around t.TypeParams().
Unpointer returns T given *T or an alias thereof.
ZeroExpr returns the ast.Expr representation of the zero value for any type t.
ZeroString returns the string representation of the zero value for any type t.

# Constants

AmbiguousSelector occurs when a selector is ambiguous.
BadDecl occurs when a declaration has invalid syntax.
BadDotDotDotSyntax occurs when a "..." occurs in a context where it is not valid.
BadImportPath occurs when an import path is not valid.
BadOffsetofSyntax occurs when unsafe.Offsetof is called with an argument that is not a selector expression.
BadRecv occurs when a method declaration does not have exactly one receiver parameter.
BadTypeKeyword occurs when a .(type) expression is used anywhere other than a type switch.
BlankIfaceMethod occurs when a method name is '_'.
BlankPkgName occurs when a package name is the blank identifier "_".
BrokenImport occurs when importing a package fails.
CannotInferTypeArgs occurs when type or function type argument inference fails to infer all type arguments.
DivByZero occurs when a division operation is provable at compile time to be a division by zero.
DuplicateCase occurs when a type or expression switch has duplicate cases.
DuplicateDecl occurs when an identifier is declared multiple times.
DuplicateDefault occurs when a type or expression switch has multiple default clauses.
DuplicateFieldAndMethod occurs when an identifier appears as both a field and method name.
DuplicateLabel occurs when a label is declared more than once.
DuplicateLitField occurs when a struct literal contains duplicated fields.
DuplicateLitKey occurs when an index is duplicated in a slice, array, or map literal.
DuplicateMethod occurs when two methods on the same receiver type have the same name.
a struct field.
ImportCRenamed occurs when the special import "C" is renamed.
ImpossibleAssert occurs for a type assertion x.(T) when the value x of interface cannot have dynamic type T, due to a missing or mismatching method on T.
IncomparableMapKey occurs when a map key type does not support the == and != operators.
IncompatibleAssign occurs when the type of the right-hand side expression in an assignment cannot be assigned to the type of the variable being assigned.
InvalidAppend occurs when append is called with a first argument that is not a slice.
InvalidArrayLen occurs when an array length is not a constant value.
InvalidAssert occurs when a type assertion is applied to a value that is not of interface type.
InvalidBlank occurs when a blank identifier is used as a value or type.
InvalidCall occurs when an expression is called that is not of function type.
InvalidCap occurs when an argument to the cap built-in function is not of supported type.
InvalidChanAssign occurs when a chan assignment is invalid.
InvalidChanRange occurs when a send-only channel used in a range expression.
InvalidClose occurs when close(...) is called with an argument that is not of channel type, or that is a receive-only channel.
InvalidComplex occurs when the complex built-in function is called with arguments with incompatible types.
InvalidCond occurs when an if condition is not a boolean expression.
InvalidConstInit occurs when a const declaration has a non-constant initializer.
InvalidConstType occurs when the underlying type in a const declaration is not a valid constant type.
InvalidConstVal occurs when a const value cannot be converted to its target type.
InvalidConversion occurs when the argument type cannot be converted to the target.
InvalidCopy occurs when the arguments are not of slice type or do not have compatible type.
InvalidDeclCycle occurs when a declaration cycle is not valid.
InvalidDefer occurs when a deferred expression is not a function call, for example if the expression is a type conversion.
InvalidDelete occurs when the delete built-in function is called with a first argument that is not a map.
InvalidDotDotDot occurs when a "..." is used in a non-variadic built-in function.
InvalidDotDotDotOperand occurs when a "..." operator is applied to a single-valued operand.
InvalidExprSwitch occurs when a switch expression is not comparable.
InvalidGo occurs when a go expression is not a function call, for example if the expression is a type conversion.
InvalidIfaceAssign occurs when a value of type T is used as an interface, but T does not implement a method of the expected interface.
InvalidIfaceEmbed occurs when a non-interface type is embedded in an interface.
InvalidImag occurs when the imag built-in function is called with an argument that does not have complex type.
InvalidIndex occurs when an index argument is not of integer type, negative, or out-of-bounds.
InvalidIndirection occurs when a non-pointer value is indirected via the '*' operator.
InvalidInitCycle occurs when an invalid cycle is detected within the initialization graph.
InvalidInitDecl occurs when init is declared as anything other than a function.
InvalidInitSig occurs when an init function declares parameters or results.
InvalidInstanceCycle occurs when an invalid cycle is detected within the instantiation graph.
InvalidIota occurs when the predeclared identifier iota is used outside of a constant declaration.
InvalidIterVar occurs when two iteration variables are used while ranging over a channel.
InvalidLen occurs when an argument to the len built-in function is not of supported type.
InvalidLit occurs when a composite literal expression does not match its type.
InvalidLitField occurs when a field name is not a valid identifier.
InvalidLitIndex occurs when the key in a key-value element of a slice or array literal is not an integer constant.
InvalidMainDecl occurs when main is declared as anything other than a function, in a main package.
InvalidMake occurs when make is called with an unsupported type argument.
InvalidMethodExpr occurs when a pointer method is called but the argument is not addressable.
InvalidMethodTypeParams occurs when methods have type parameters.
InvalidOffsetof occurs when unsafe.Offsetof is called with a method selector, rather than a field selector, or when the field is embedded via a pointer.
InvalidPkgUse occurs when a package identifier is used outside of a selector expression.
InvalidPostDecl occurs when there is a declaration in a for-loop post statement.
InvalidPtrEmbed occurs when an embedded field is of the pointer form *T, and T itself is itself a pointer, an unsafe.Pointer, or an interface.
InvalidRangeExpr occurs when the type of a range expression is not array, slice, string, map, or channel.
InvalidReal occurs when the real built-in function is called with an argument that does not have complex type.
InvalidReceive occurs when there is a channel receive from a value that is either not a channel, or is a send-only channel.
InvalidRecv occurs when a receiver type expression is not of the form T or *T, or T is a pointer type.
InvalidSelectCase occurs when a select case is not a channel send or receive.
InvalidSend occurs when there is a channel send to a value that is not a channel, or is a receive-only channel.
InvalidShiftCount occurs when the right-hand side of a shift operation is either non-integer, negative, or too large.
InvalidShiftOperand occurs when the shifted operand is not an integer.
InvalidSliceExpr occurs when a three-index slice expression (a[x:y:z]) is applied to a string.
InvalidStructLit occurs when a positional struct literal has an incorrect number of values.
InvalidSyntaxTree occurs if an invalid syntax tree is provided to the type checker.
arguments? InferenceFailed.
InvalidTypeCycle occurs when a cycle in type definitions results in a type that is not well-defined.
InvalidTypeSwitch occurs when .(type) is used on an expression that is not of interface type.
InvalidUnion occurs when an embedded union or approximation element is not valid.
InvalidUnsafeAdd occurs when unsafe.Add is called with a length argument that is not of integer type.
InvalidUnsafeSlice occurs when unsafe.Slice is called with a pointer argument that is not of pointer type or a length argument that is not of integer type, negative, or out of bounds.
InvalidUnsafeSliceData occurs when unsafe.SliceData is called with an argument that is not of slice type.
InvalidUnsafeString occurs when unsafe.String is called with a length argument that is not of integer type, negative, or out of bounds.
InvalidUntypedConversion occurs when there is no valid implicit conversion from an untyped value satisfying the type constraints of the context in which it is used.
JumpIntoBlock occurs when a forward jump goes to a label inside a nested block.
JumpOverDecl occurs when a label jumps over a variable declaration.
a local variable.
MismatchedPkgName occurs when a file's package name doesn't match the package name already established by other files.
MismatchedTypes occurs when operand types are incompatible in a binary operation.
MisplacedBreak occurs when a break statement is not within a for, switch, or select statement of the innermost function definition.
MisplacedConstraintIface occurs when a constraint-type interface is used outside of constraint position.
MisplacedContinue occurs when a continue statement is not within a for loop of the innermost function definition.
MisplacedDotDotDot occurs when a "..." is used somewhere other than the final argument to a function call.
MisplacedFallthrough occurs when a fallthrough statement is not within an expression switch.
MisplacedLabel occurs when a break or continue label is not on a for, switch, or select statement.
MisplacedTypeParam occurs when a type parameter is used in a place where it is not permitted.
MissingFieldOrMethod occurs when a selector references a field or method that does not exist.
MissingInitBody occurs when an init function is missing its body.
MissingLitField occurs when a struct literal refers to a field that does not exist on the struct type.
MissingLitKey occurs when a map literal is missing a key expression.
MissingReturn occurs when a function with results is missing a return statement.
MixedStructLit occurs when a struct literal contains a mix of positional and named elements.
MultiValAssignOp occurs when an assignment operation (+=, *=, etc) does not have single-valued left-hand or right-hand side.
NoNewVar occurs when a short variable declaration (':=') does not declare new variables.
NonIndexableOperand occurs when an index operation is applied to a value that cannot be indexed.
NonNumericIncDec occurs when an increment or decrement operator is applied to a non-numeric value.
NonSliceableOperand occurs when a slice operation is applied to a value whose type is not sliceable, or is unaddressable.
NonVariadicDotDotDot occurs when a "..." is used on the final argument to a non-variadic function.
NotAGenericType occurs when a non-generic type is used where a generic type is expected: in type or function instantiation.
NotAnExpr occurs when a type expression is used where a value expression is expected.
NotAType occurs when the identifier used as the underlying type in a type declaration or the right-hand side of a type alias does not denote a type.
NumericOverflow occurs when a numeric constant overflows its target type.
OutOfScopeResult occurs when the name of a value implicitly returned by an empty return statement is shadowed in a nested scope.
OversizeArrayLit occurs when an array literal exceeds its length.
a package-level variable.
a function parameter variable.
a method receiver variable.
RepeatedDecl occurs when an identifier occurs more than once on the left hand side of a short variable declaration.
a function result variable.
SwappedMakeArgs occurs when make is called with three arguments, and its length argument is larger than its capacity argument.
SwappedSliceIndices occurs when constant indices in a slice expression are decreasing in value.
Test is reserved for errors that only apply while in self-test mode.
TooManyValues occurs when a function returns too many values for the expression context in which it is used.
TruncatedFloat occurs when a float constant is truncated to an integer value.
UnaddressableFieldAssign occurs when trying to assign to a struct field in a map value.
UnaddressableOperand occurs when the & operator is applied to an unaddressable expression.
UnassignableOperand occurs when the left-hand side of an assignment is not assignable.
UncalledBuiltin occurs when a built-in function is used as a function-valued expression, instead of being called.
UndeclaredImportedName occurs when a package-qualified identifier is undeclared by the imported package.
UndeclaredLabel occurs when an undeclared label is jumped to.
UndeclaredName occurs when an identifier is not declared in the current scope.
UndefinedOp occurs when an operator is not defined for the type(s) used in an operation.
UnexportedLitField occurs when a positional struct literal implicitly assigns an unexported field of an imported type.
UnexportedName occurs when a selector refers to an unexported identifier of an imported package.
UnsupportedFeature occurs when a language feature is used that is not supported at this Go version.
UntypedLit occurs when a composite literal omits a required type identifier.
UntypedNilUse occurs when the predeclared (untyped) value nil is used to initialize a variable declared without an explicit type.
UnusedExpr occurs when a side-effect free expression is used as a statement.
UnusedImport occurs when an import is unused.
UnusedLabel occurs when a label is declared but not used.
UnusedResults occurs when a restricted expression-only built-in function is suspended via go or defer.
UnusedVar occurs when a variable is declared but unused.
WrongArgCount occurs when too few or too many arguments are passed by a function call.
WrongAssignCount occurs when the number of values on the right-hand side of an assignment or initialization expression does not match the number of variables on the left-hand side.
WrongResultCount occurs when a return statement returns an incorrect number of values.
WrongTypeArgCount occurs when a type or function is instantiated with an incorrect number of type arguments, including when a generic type or function is used without instantiation.

# Interfaces

A NamedOrAlias is a [types.Type] that is named (as defined by the spec) and capable of bearing type parameters: it abstracts aliases ([types.Alias]) and defined types ([types.Named]).

# Type aliases

No description provided by the author
No description provided by the author