Documentation
¶
Overview ¶
Package reflect implements run-time reflection, allowing a program to manipulate objects with arbitrary types. The typical use is to take a value with static type interface{} and extract its dynamic type information by calling TypeOf, which returns a Type.
A call to ValueOf returns a Value representing the run-time data. Zero takes a Type and returns a Value representing a zero value for that type.
See "The Laws of Reflection" for an introduction to reflection in Go: https://golang.org/doc/articles/laws_of_reflection.html
Index ¶
- Constants
- func Copy(dst, src Value) int
- func DeepEqual(x, y any) bool
- func Swapper(slice any) func(i, j int)
- func TypeAssert[T any](v Value) (T, bool)
- type ChanDir
- type Kind
- type MapIter
- type Method
- type SelectCase
- type SelectDir
- type SliceHeaderdeprecated
- type StringHeaderdeprecated
- type StructField
- type StructTag
- type Type
- func ArrayOf(length int, elem Type) Type
- func ChanOf(dir ChanDir, t Type) Type
- func FuncOf(in, out []Type, variadic bool) Type
- func MapOf(key, elem Type) Type
- func PointerTo(t Type) Type
- func PtrTo(t Type) Typedeprecated
- func SliceOf(t Type) Type
- func StructOf(fields []StructField) Type
- func TypeFor[T any]() Type
- func TypeOf(i any) Type
- type Value
- func Append(s Value, x ...Value) Value
- func AppendSlice(s, t Value) Value
- func Indirect(v Value) Value
- func MakeChan(typ Type, buffer int) Value
- func MakeFunc(typ Type, fn func(args []Value) (results []Value)) Value
- func MakeMap(typ Type) Value
- func MakeMapWithSize(typ Type, n int) Value
- func MakeSlice(typ Type, len, cap int) Value
- func New(typ Type) Value
- func NewAt(typ Type, p unsafe.Pointer) Value
- func Select(cases []SelectCase) (chosen int, recv Value, recvOK bool)
- func SliceAt(typ Type, p unsafe.Pointer, n int) Value
- func ValueOf(i any) Value
- func Zero(typ Type) Value
- func (v Value) Addr() Value
- func (v Value) Bool() bool
- func (v Value) Bytes() []byte
- func (v Value) Call(in []Value) []Value
- func (v Value) CallSlice(in []Value) []Value
- func (v Value) CanAddr() bool
- func (v Value) CanComplex() bool
- func (v Value) CanConvert(t Type) bool
- func (v Value) CanFloat() bool
- func (v Value) CanInt() bool
- func (v Value) CanInterface() bool
- func (v Value) CanSet() bool
- func (v Value) CanUint() bool
- func (v Value) Cap() int
- func (v Value) Clear()
- func (v Value) Close()
- func (v Value) Comparable() bool
- func (v Value) Complex() complex128
- func (v Value) Convert(t Type) Value
- func (v Value) Elem() Value
- func (v Value) Equal(u Value) bool
- func (v Value) Field(i int) Value
- func (v Value) FieldByIndex(index []int) Value
- func (v Value) FieldByIndexErr(index []int) (Value, error)
- func (v Value) FieldByName(name string) Value
- func (v Value) FieldByNameFunc(match func(string) bool) Value
- func (v Value) Fields() iter.Seq2[StructField, Value]
- func (v Value) Float() float64
- func (v Value) Grow(n int)
- func (v Value) Index(i int) Value
- func (v Value) Int() int64
- func (v Value) Interface() (i any)
- func (v Value) InterfaceData() [2]uintptrdeprecated
- func (v Value) IsNil() bool
- func (v Value) IsValid() bool
- func (v Value) IsZero() bool
- func (v Value) Kind() Kind
- func (v Value) Len() int
- func (v Value) MapIndex(key Value) Value
- func (v Value) MapKeys() []Value
- func (v Value) MapRange() *MapIter
- func (v Value) Method(i int) Value
- func (v Value) MethodByName(name string) Value
- func (v Value) Methods() iter.Seq2[Method, Value]
- func (v Value) NumField() int
- func (v Value) NumMethod() int
- func (v Value) OverflowComplex(x complex128) bool
- func (v Value) OverflowFloat(x float64) bool
- func (v Value) OverflowInt(x int64) bool
- func (v Value) OverflowUint(x uint64) bool
- func (v Value) Pointer() uintptr
- func (v Value) Recv() (x Value, ok bool)
- func (v Value) Send(x Value)
- func (v Value) Seq() iter.Seq[Value]
- func (v Value) Seq2() iter.Seq2[Value, Value]
- func (v Value) Set(x Value)
- func (v Value) SetBool(x bool)