Documentation
¶
Index ¶
- func IsJsObject(t types.Type) bool
- func IsJsPackage(pkg *types.Package) bool
- func IsMethod(o types.Object) bool
- func OffsetOf(sizes types.Sizes, sel Selection) int64
- func RecvAsFirstArg(sig *types.Signature) *types.Signature
- func RecvType(sig *types.Signature) *types.Named
- type Map
- type Selection
- type Signature
- type TypeList
- type TypeNames
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsJsObject ¶
func IsJsPackage ¶
func OffsetOf ¶
OffsetOf returns byte offset of a struct field specified by the provided selection.
Adapted from go/types.Config.offsetof().
func RecvAsFirstArg ¶
RecvAsFirstArg takes a method signature and returns a function signature with receiver as the first parameter.
Types ¶
type Map ¶
type Map[Val any] struct { // contains filtered or unexported fields }
Map is a type-safe wrapper around golang.org/x/tools/go/types/typeutil.Map.
type Selection ¶
type Selection interface { Kind() types.SelectionKind Recv() types.Type Index() []int Obj() types.Object Type() types.Type }
Selection is a common interface for go/types.Selection and our custom-constructed method and field selections.
type Signature ¶
Signature is a helper that provides convenient access to function signature type information.
func (Signature) HasNamedResults ¶
HasNamedResults returns true if the function signature returns something and returned results are names (e.g. `func () (val int, err error)`).
func (Signature) HasResults ¶
HasResults returns true if the function signature returns something.
func (Signature) Param ¶
Param returns the expected argument type for the i'th argument position.
This function is able to return correct expected types for variadic calls both when ellipsis syntax (e.g. myFunc(requiredArg, optionalArgSlice...)) is used and when optional args are passed individually.
The returned types may differ from the actual argument expression types if there is an implicit type conversion involved (e.g. passing a struct into a function that expects an interface).
func (Signature) RequiredParams ¶
RequiredParams returns the number of required parameters in the function signature.
func (Signature) VariadicType ¶
VariadicType returns the slice-type corresponding to the signature's variadic parameter, or nil of the signature is not variadic. With the exception of the special-case `append([]byte{}, "string"...)`, the returned type is `*types.Slice` and `.Elem()` method can be used to get the type of individual arguments.
type TypeList ¶
TypeList an ordered list of types.
type TypeNames ¶
type TypeNames struct {
// contains filtered or unexported fields
}
TypeNames implements an ordered set of *types.TypeName pointers.
The set is ordered to ensure deterministic behavior across compiler runs.