type Value … type flag … const flagKindWidth … const flagKindMask … const flagStickyRO … const flagEmbedRO … const flagIndir … const flagAddr … const flagMethod … const flagMethodShift … const flagRO … func (f flag) kind() Kind { … } func (f flag) ro() flag { … } func (v Value) typ() *abi.Type { … } // pointer returns the underlying pointer represented by v. // v.Kind() must be Pointer, Map, Chan, Func, or UnsafePointer // if v.Kind() == Pointer, the base type must not be not-in-heap. func (v Value) pointer() unsafe.Pointer { … } // packEface converts v to the empty interface. func packEface(v Value) any { … } // unpackEface converts the empty interface i to a Value. func unpackEface(i any) Value { … } type ValueError … func (e *ValueError) Error() string { … } // valueMethodName returns the name of the exported calling method on Value. func valueMethodName() string { … } type nonEmptyInterface … // mustBe panics if f's kind is not expected. // Making this a method on flag instead of on Value // (and embedding flag in Value) means that we can write // the very clear v.mustBe(Bool) and have it compile into // v.flag.mustBe(Bool), which will only bother to copy the // single important word for the receiver. func (f flag) mustBe(expected Kind) { … } // mustBeExported panics if f records that the value was obtained using // an unexported field. func (f flag) mustBeExported() { … } func (f flag) mustBeExportedSlow() { … } // mustBeAssignable panics if f records that the value is not assignable, // which is to say that either it was obtained using an unexported field // or it is not addressable. func (f flag) mustBeAssignable() { … } func (f flag) mustBeAssignableSlow() { … } // Addr returns a pointer value representing the address of v. // It panics if [Value.CanAddr] returns false. // Addr is typically used to obtain a pointer to a struct field // or slice element in order to call a method that requires a // pointer receiver. func (v Value) Addr() Value { … } // Bool returns v's underlying value. // It panics if v's kind is not [Bool]. func (v Value) Bool() bool { … } func (v Value) panicNotBool() { … } var bytesType … // Bytes returns v's underlying value. // It panics if v's underlying value is not a slice of bytes or // an addressable array of bytes. func (v Value) Bytes() []byte { … } func (v Value) bytesSlow() []byte { … } // runes returns v's underlying value. // It panics if v's underlying value is not a slice of runes (int32s). func (v Value) runes() []rune { … } // CanAddr reports whether the value's address can be obtained with [Value.Addr]. // Such values are called addressable. A value is addressable if it is // an element of a slice, an element of an addressable array, // a field of an addressable struct, or the result of dereferencing a pointer. // If CanAddr returns false, calling [Value.Addr] will panic. func (v Value) CanAddr() bool { … } // CanSet reports whether the value of v can be changed. // A [Value] can be changed only if it is addressable and was not // obtained by the use of unexported struct fields. // If CanSet returns false, calling [Value.Set] or any type-specific // setter (e.g., [Value.SetBool], [Value.SetInt]) will panic. func (v Value) CanSet() bool { … } // Call calls the function v with the input arguments in. // For example, if len(in) == 3, v.Call(in) represents the Go call v(in[0], in[1], in[2]). // Call panics if v's Kind is not [Func]. // It returns the output results as Values. // As in Go, each input argument must be assignable to the // type of the function's corresponding input parameter. // If v is a variadic function, Call creates the variadic slice parameter // itself, copying in the corresponding values. func (v Value) Call(in []Value) []Value { … } // CallSlice calls the variadic function v with the input arguments in, // assigning the slice in[len(in)-1] to v's final variadic argument. // For example, if len(in) == 3, v.CallSlice(in) represents the Go call v(in[0], in[1], in[2]...). // CallSlice panics if v's Kind is not [Func] or if v is not variadic. // It returns the output results as Values. // As in Go, each input argument must be assignable to the // type of the function's corresponding input parameter. func (v Value) CallSlice(in []Value) []Value { … } var callGC … const debugReflectCall … func (v Value) call(op string, in []Value) []Value { … } // callReflect is the call implementation used by a function // returned by MakeFunc. In many ways it is the opposite of the // method Value.call above. The method above converts a call using Values // into a call of a function with a concrete argument frame, while // callReflect converts a call of a function with a concrete argument // frame into a call using Values. // It is in this file so that it can be next to the call method above. // The remainder of the MakeFunc implementation is in makefunc.go. // // NOTE: This function must be marked as a "wrapper" in the generated code, // so that the linker can make it work correctly for panic and recover. // The gc compilers know to do that for the name "reflect.callReflect". // // ctxt is the "closure" generated by MakeFunc. // frame is a pointer to the arguments to that closure on the stack. // retValid points to a boolean which should be set when the results // section of frame is set. // // regs contains the argument values passed in registers and will contain // the values returned from ctxt.fn in registers. func callReflect(ctxt *makeFuncImpl, frame unsafe.Pointer, retValid *bool, regs *abi.RegArgs) { … } // methodReceiver returns information about the receiver // described by v. The Value v may or may not have the // flagMethod bit set, so the kind cached in v.flag should // not be used. // The return value rcvrtype gives the method's actual receiver type. // The return value t gives the method type signature (without the receiver). // The return value fn is a pointer to the method code. func methodReceiver(op string, v Value, methodIndex int) (rcvrtype *abi.Type, t *funcType, fn unsafe.Pointer) { … } // v is a method receiver. Store at p the word which is used to // encode that receiver at the start of the argument list. // Reflect uses the "interface" calling convention for // methods, which always uses one word to record the receiver. func storeRcvr(v Value, p unsafe.Pointer) { … } // align returns the result of rounding x up to a multiple of n. // n must be a power of two. func align(x, n uintptr) uintptr { … } // callMethod is the call implementation used by a function returned // by makeMethodValue (used by v.Method(i).Interface()). // It is a streamlined version of the usual reflect call: the caller has // already laid out the argument frame for us, so we don't have // to deal with individual Values for each argument. // It is in this file so that it can be next to the two similar functions above. // The remainder of the makeMethodValue implementation is in makefunc.go. // // NOTE: This function must be marked as a "wrapper" in the generated code, // so that the linker can make it work correctly for panic and recover. // The gc compilers know to do that for the name "reflect.callMethod". // // ctxt is the "closure" generated by makeMethodValue. // frame is a pointer to the arguments to that closure on the stack. // retValid points to a boolean which should be set when the results // section of frame is set. // // regs contains the argument values passed in registers and will contain // the values returned from ctxt.fn in registers. func callMethod(ctxt *methodValue, frame unsafe.Pointer, retValid *bool, regs *abi.RegArgs) { … } // funcName returns the name of f, for use in error messages. func funcName(f func([]Value) []Value) string { … } // Cap returns v's capacity. // It panics if v's Kind is not [Array], [Chan], [Slice] or pointer to [Array]. func (v Value) Cap() int { … } func (v Value) capNonSlice() int { … } // Close closes the channel v. // It panics if v's Kind is not [Chan] or // v is a receive-only channel. func (v Value) Close() { … } // CanComplex reports whether [Value.Complex] can be used without panicking. func (v Value) CanComplex() bool { … } // Complex returns v's underlying value, as a complex128. // It panics if v's Kind is not [Complex64] or [Complex128] func (v Value) Complex() complex128 { … } // Elem returns the value that the interface v contains // or that the pointer v points to. // It panics if v's Kind is not [Interface] or [Pointer]. // It returns the zero Value if v is nil. func (v Value) Elem() Value { … } // Field returns the i'th field of the struct v. // It panics if v's Kind is not [Struct] or i is out of range. func (v Value) Field(i int) Value { … } // FieldByIndex returns the nested field corresponding to index. // It panics if evaluation requires stepping through a nil // pointer or a field that is not a struct. func (v Value) FieldByIndex(index []int) Value { … } // FieldByIndexErr returns the nested field corresponding to index. // It returns an error if evaluation requires stepping through a nil // pointer, but panics if it must step through a field that // is not a struct. func (v Value) FieldByIndexErr(index []int) (Value, error) { … } // FieldByName returns the struct field with the given name. // It returns the zero Value if no field was found. // It panics if v's Kind is not [Struct]. func (v Value) FieldByName(name string) Value { … } // FieldByNameFunc returns the struct field with a name // that satisfies the match function. // It panics if v's Kind is not [Struct]. // It returns the zero Value if no field was found. func (v Value) FieldByNameFunc(match func(string) bool) Value { … } // CanFloat reports whether [Value.Float] can be used without panicking. func (v Value) CanFloat() bool { … } // Float returns v's underlying value, as a float64. // It panics if v's Kind is not [Float32] or [Float64] func (v Value) Float() float64 { … } var uint8Type … // Index returns v's i'th element. // It panics if v's Kind is not [Array], [Slice], or [String] or i is out of range. func (v Value) Index(i int) Value { … } // CanInt reports whether Int can be used without panicking. func (v Value) CanInt() bool { … } // Int returns v's underlying value, as an int64. // It panics if v's Kind is not [Int], [Int8], [Int16], [Int32], or [Int64]. func (v Value) Int() int64 { … } // CanInterface reports whether [Value.Interface] can be used without panicking. func (v Value) CanInterface() bool { … } // Interface returns v's current value as an interface{}. // It is equivalent to: // // var i interface{} = (v's underlying value) // // It panics if the Value was obtained by accessing // unexported struct fields. func (v Value) Interface() (i any) { … } func valueInterface(v Value, safe bool) any { … } // InterfaceData returns a pair of unspecified uintptr values. // It panics if v's Kind is not Interface. // // In earlier versions of Go, this function returned the interface's // value as a uintptr pair. As of Go 1.4, the implementation of // interface values precludes any defined use of InterfaceData. // // Deprecated: The memory representation of interface values is not // compatible with InterfaceData. func (v Value) InterfaceData() [2]uintptr { … } // IsNil reports whether its argument v is nil. The argument must be // a chan, func, interface, map, pointer, or slice value; if it is // not, IsNil panics. Note that IsNil is not always equivalent to a // regular comparison with nil in Go. For example, if v was created // by calling [ValueOf] with an uninitialized interface variable i, // i==nil will be true but v.IsNil will panic as v will be the zero // Value. func (v Value) IsNil() bool { … } // IsValid reports whether v represents a value. // It returns false if v is the zero Value. // If [Value.IsValid] returns false, all other methods except String panic. // Most functions and methods never return an invalid Value. // If one does, its documentation states the conditions explicitly. func (v Value) IsValid() bool { … } // IsZero reports whether v is the zero value for its type. // It panics if the argument is invalid. func (v Value) IsZero() bool { … } // isZero For all zeros, performance is not as good as // return bytealg.Count(b, byte(0)) == len(b) func isZero(b []byte) bool { … } // SetZero sets v to be the zero value of v's type. // It panics if [Value.CanSet] returns false. func (v Value) SetZero() { … } // Kind returns v's Kind. // If v is the zero Value ([Value.IsValid] returns false), Kind returns Invalid. func (v Value) Kind() Kind { … } // Len returns v's length. // It panics if v's Kind is not [Array], [Chan], [Map], [Slice], [String], or pointer to [Array]. func (v Value) Len() int { … } func (v Value) lenNonSlice() int { … } // copyVal returns a Value containing the map key or value at ptr, // allocating a new variable as needed. func copyVal(typ *abi.Type, fl flag, ptr unsafe.Pointer) Value { … } // Method returns a function value corresponding to v's i'th method. // The arguments to a Call on the returned function should not include // a receiver; the returned function will always use v as the receiver. // Method panics if i is out of range or if v is a nil interface value. func (v Value) Method(i int) Value { … } // NumMethod returns the number of methods in the value's method set. // // For a non-interface type, it returns the number of exported methods. // // For an interface type, it returns the number of exported and unexported methods. func (v Value) NumMethod() int { … } // MethodByName returns a function value corresponding to the method // of v with the given name. // The arguments to a Call on the returned function should not include // a receiver; the returned function will always use v as the receiver. // It returns the zero Value if no method was found. func (v Value) MethodByName(name string) Value { … } // NumField returns the number of fields in the struct v. // It panics if v's Kind is not [Struct]. func (v Value) NumField() int { … } // OverflowComplex reports whether the complex128 x cannot be represented by v's type. // It panics if v's Kind is not [Complex64] or [Complex128]. func (v Value) OverflowComplex(x complex128) bool { … } // OverflowFloat reports whether the float64 x cannot be represented by v's type. // It panics if v's Kind is not [Float32] or [Float64]. func (v Value) OverflowFloat(x float64) bool { … } func overflowFloat32(x float64) bool { … } // OverflowInt reports whether the int64 x cannot be represented by v's type. // It panics if v's Kind is not [Int], [Int8], [Int16], [Int32], or [Int64]. func (v Value) OverflowInt(x int64) bool { … } // OverflowUint reports whether the uint64 x cannot be represented by v's type. // It panics if v's Kind is not [Uint], [Uintptr], [Uint8], [Uint16], [Uint32], or [Uint64]. func (v Value) OverflowUint(x uint64) bool { … } // Pointer returns v's value as a uintptr. // It panics if v's Kind is not [Chan], [Func], [Map], [Pointer], [Slice], [String], or [UnsafePointer]. // // If v's Kind is [Func], the returned pointer is an underlying // code pointer, but not necessarily enough to identify a // single function uniquely. The only guarantee is that the // result is zero if and only if v is a nil func Value. // // If v's Kind is [Slice], the returned pointer is to the first // element of the slice. If the slice is nil the returned value // is 0. If the slice is empty but non-nil the return value is non-zero. // // If v's Kind is [String], the returned pointer is to the first // element of the underlying bytes of string. // // It's preferred to use uintptr(Value.UnsafePointer()) to get the equivalent result. func (v Value) Pointer() uintptr { … } // Recv receives and returns a value from the channel v. // It panics if v's Kind is not [Chan]. // The receive blocks until a value is ready. // The boolean value ok is true if the value x corresponds to a send // on the channel, false if it is a zero value received because the channel is closed. func (v Value) Recv() (x Value, ok bool) { … } // internal recv, possibly non-blocking (nb). // v is known to be a channel. func (v Value) recv(nb bool) (val Value, ok bool) { … } // Send sends x on the channel v. // It panics if v's kind is not [Chan] or if x's type is not the same type as v's element type. // As in Go, x's value must be assignable to the channel's element type. func (v Value) Send(x Value) { … } // internal send, possibly non-blocking. // v is known to be a channel. func (v Value) send(x Value, nb bool) (selected bool) { … } // Set assigns x to the value v. // It panics if [Value.CanSet] returns false. // As in Go, x's value must be assignable to v's type and // must not be derived from an unexported field. func (v Value) Set(x Value) { … } // SetBool sets v's underlying value. // It panics if v's Kind is not [Bool] or if [Value.CanSet] returns false. func (v Value) SetBool(x bool) { … } // SetBytes sets v's underlying value. // It panics if v's underlying value is not a slice of bytes. func (v Value) SetBytes(x []byte) { … } // setRunes sets v's underlying value. // It panics if v's underlying value is not a slice of runes (int32s). func (v Value) setRunes(x []rune) { … } // SetComplex sets v's underlying value to x. // It panics if v's Kind is not [Complex64] or [Complex128], or if [Value.CanSet] returns false. func (v Value) SetComplex(x complex128) { … } // SetFloat sets v's underlying value to x. // It panics if v's Kind is not [Float32] or [Float64], or if [Value.CanSet] returns false. func (v Value) SetFloat(x float64) { … } // SetInt sets v's underlying value to x. // It panics if v's Kind is not [Int], [Int8], [Int16], [Int32], or [Int64], or if [Value.CanSet] returns false. func (v Value) SetInt(x int64) { … } // SetLen sets v's length to n. // It panics if v's Kind is not [Slice] or if n is negative or // greater than the capacity of the slice. func (v Value) SetLen(n int) { … } // SetCap sets v's capacity to n. // It panics if v's Kind is not [Slice] or if n is smaller than the length or // greater than the capacity of the slice. func (v Value) SetCap(n int) { … } // SetUint sets v's underlying value to x. // It panics if v's Kind is not [Uint], [Uintptr], [Uint8], [Uint16], [Uint32], or [Uint64], or if [Value.CanSet] returns false. func (v Value) SetUint(x uint64) { … } // SetPointer sets the [unsafe.Pointer] value v to x. // It panics if v's Kind is not [UnsafePointer]. func (v Value) SetPointer(x unsafe.Pointer) { … } // SetString sets v's underlying value to x. // It panics if v's Kind is not [String] or if [Value.CanSet] returns false. func (v Value) SetString(x string) { … } // Slice returns v[i:j]. // It panics if v's Kind is not [Array], [Slice] or [String], or if v is an unaddressable array, // or if the indexes are out of bounds. func (v Value) Slice(i, j int) Value { … } // Slice3 is the 3-index form of the slice operation: it returns v[i:j:k]. // It panics if v's Kind is not [Array] or [Slice], or if v is an unaddressable array, // or if the indexes are out of bounds. func (v Value) Slice3(i, j, k int) Value { … } // String returns the string v's underlying value, as a string. // String is a special case because of Go's String method convention. // Unlike the other getters, it does not panic if v's Kind is not [String]. // Instead, it returns a string of the form "<T value>" where T is v's type. // The fmt package treats Values specially. It does not call their String // method implicitly but instead prints the concrete values they hold. func (v Value) String() string { … } func (v Value) stringNonString() string { … } // TryRecv attempts to receive a value from the channel v but will not block. // It panics if v's Kind is not [Chan]. // If the receive delivers a value, x is the transferred value and ok is true. // If the receive cannot finish without blocking, x is the zero Value and ok is false. // If the channel is closed, x is the zero value for the channel's element type and ok is false. func (v Value) TryRecv() (x Value, ok bool) { … } // TrySend attempts to send x on the channel v but will not block. // It panics if v's Kind is not [Chan]. // It reports whether the value was sent. // As in Go, x's value must be assignable to the channel's element type. func (v Value) TrySend(x Value) bool { … } // Type returns v's type. func (v Value) Type() Type { … } func (v Value) typeSlow() Type { … } // CanUint reports whether [Value.Uint] can be used without panicking. func (v Value) CanUint() bool { … } // Uint returns v's underlying value, as a uint64. // It panics if v's Kind is not [Uint], [Uintptr], [Uint8], [Uint16], [Uint32], or [Uint64]. func (v Value) Uint() uint64 { … } // UnsafeAddr returns a pointer to v's data, as a uintptr. // It panics if v is not addressable. // // It's preferred to use uintptr(Value.Addr().UnsafePointer()) to get the equivalent result. func (v Value) UnsafeAddr() uintptr { … } // UnsafePointer returns v's value as a [unsafe.Pointer]. // It panics if v's Kind is not [Chan], [Func], [Map], [Pointer], [Slice], [String] or [UnsafePointer]. // // If v's Kind is [Func], the returned pointer is an underlying // code pointer, but not necessarily enough to identify a // single function uniquely. The only guarantee is that the // result is zero if and only if v is a nil func Value. // // If v's Kind is [Slice], the returned pointer is to the first // element of the slice. If the slice is nil the returned value // is nil. If the slice is empty but non-nil the return value is non-nil. // // If v's Kind is [String], the returned pointer is to the first // element of the underlying bytes of string. func (v Value) UnsafePointer() unsafe.Pointer { … } type StringHeader … type SliceHeader … func typesMustMatch(what string, t1, t2 Type) { … } // arrayAt returns the i-th element of p, // an array whose elements are eltSize bytes wide. // The array pointed at by p must have at least i+1 elements: // it is invalid (but impossible to check here) to pass i >= len, // because then the result will point outside the array. // whySafe must explain why i < len. (Passing "i < len" is fine; // the benefit is to surface this assumption at the call site.) func arrayAt(p unsafe.Pointer, i int, eltSize uintptr, whySafe string) unsafe.Pointer { … } // Grow increases the slice's capacity, if necessary, to guarantee space for // another n elements. After Grow(n), at least n elements can be appended // to the slice without another allocation. // // It panics if v's Kind is not a [Slice] or if n is negative or too large to // allocate the memory. func (v Value) Grow(n int) { … } // grow is identical to Grow but does not check for assignability. func (v Value) grow(n int) { … } // extendSlice extends a slice by n elements. // // Unlike Value.grow, which modifies the slice in place and // does not change the length of the slice in place, // extendSlice returns a new slice value with the length // incremented by the number of specified elements. func (v Value) extendSlice(n int) Value { … } // Clear clears the contents of a map or zeros the contents of a slice. // // It panics if v's Kind is not [Map] or [Slice]. func (v Value) Clear() { … } // Append appends the values x to a slice s and returns the resulting slice. // As in Go, each x's value must be assignable to the slice's element type. func Append(s Value, x ...Value) Value { … } // AppendSlice appends a slice t to a slice s and returns the resulting slice. // The slices s and t must have the same element type. func AppendSlice(s, t Value) Value { … } // Copy copies the contents of src into dst until either // dst has been filled or src has been exhausted. // It returns the number of elements copied. // Dst and src each must have kind [Slice] or [Array], and // dst and src must have the same element type. // // As a special case, src can have kind [String] if the element type of dst is kind [Uint8]. func Copy(dst, src Value) int { … } type runtimeSelect … // rselect runs a select. It returns the index of the chosen case. // If the case was a receive, val is filled in with the received value. // The conventional OK bool indicates whether the receive corresponds // to a sent value. // // rselect generally doesn't escape the runtimeSelect slice, except // that for the send case the value to send needs to escape. We don't // have a way to represent that in the function signature. So we handle // that with a forced escape in function Select. // //go:noescape func rselect([]runtimeSelect) (chosen int, recvOK bool) type SelectDir … const _ … const SelectSend … const SelectRecv … const SelectDefault … type SelectCase … // Select executes a select operation described by the list of cases. // Like the Go select statement, it blocks until at least one of the cases // can proceed, makes a uniform pseudo-random choice, // and then executes that case. It returns the index of the chosen case // and, if that case was a receive operation, the value received and a // boolean indicating whether the value corresponds to a send on the channel // (as opposed to a zero value received because the channel is closed). // Select supports a maximum of 65536 cases. func Select(cases []SelectCase) (chosen int, recv Value, recvOK bool) { … } //go:noescape func unsafe_New(*abi.Type) unsafe.Pointer //go:noescape func unsafe_NewArray(*abi.Type, int) unsafe.Pointer // MakeSlice creates a new zero-initialized slice value // for the specified slice type, length, and capacity. func MakeSlice(typ Type, len, cap int) Value { … } // SliceAt returns a [Value] representing a slice whose underlying // data starts at p, with length and capacity equal to n. // // This is like [unsafe.Slice]. func SliceAt(typ Type, p unsafe.Pointer, n int) Value { … } // MakeChan creates a new channel with the specified type and buffer size. func MakeChan(typ Type, buffer int) Value { … } // MakeMap creates a new map with the specified type. func MakeMap(typ Type) Value { … } // MakeMapWithSize creates a new map with the specified type // and initial space for approximately n elements. func MakeMapWithSize(typ Type, n int) Value { … } // Indirect returns the value that v points to. // If v is a nil pointer, Indirect returns a zero Value. // If v is not a pointer, Indirect returns v. func Indirect(v Value) Value { … } // ValueOf returns a new Value initialized to the concrete value // stored in the interface i. ValueOf(nil) returns the zero Value. func ValueOf(i any) Value { … } // Zero returns a Value representing the zero value for the specified type. // The result is different from the zero value of the Value struct, // which represents no value at all. // For example, Zero(TypeOf(42)) returns a Value with Kind [Int] and value 0. // The returned value is neither addressable nor settable. func Zero(typ Type) Value { … } var zeroVal … // New returns a Value representing a pointer to a new zero value // for the specified type. That is, the returned Value's Type is [PointerTo](typ). func New(typ Type) Value { … } // NewAt returns a Value representing a pointer to a value of the // specified type, using p as that pointer. func NewAt(typ Type, p unsafe.Pointer) Value { … } // assignTo returns a value v that can be assigned directly to dst. // It panics if v is not assignable to dst. // For a conversion to an interface type, target, if not nil, // is a suggested scratch space to use. // target must be initialized memory (or nil). func (v Value) assignTo(context string, dst *abi.Type, target unsafe.Pointer) Value { … } // Convert returns the value v converted to type t. // If the usual Go conversion rules do not allow conversion // of the value v to type t, or if converting v to type t panics, Convert panics. func (v Value) Convert(t Type) Value { … } // CanConvert reports whether the value v can be converted to type t. // If v.CanConvert(t) returns true then v.Convert(t) will not panic. func (v Value) CanConvert(t Type) bool { … } // Comparable reports whether the value v is comparable. // If the type of v is an interface, this checks the dynamic type. // If this reports true then v.Interface() == x will not panic for any x, // nor will v.Equal(u) for any Value u. func (v Value) Comparable() bool { … } // Equal reports true if v is equal to u. // For two invalid values, Equal will report true. // For an interface value, Equal will compare the value within the interface. // Otherwise, If the values have different types, Equal will report false. // Otherwise, for arrays and structs Equal will compare each element in order, // and report false if it finds non-equal elements. // During all comparisons, if values of the same type are compared, // and the type is not comparable, Equal will panic. func (v Value) Equal(u Value) bool { … } // convertOp returns the function to convert a value of type src // to a value of type dst. If the conversion is illegal, convertOp returns nil. func convertOp(dst, src *abi.Type) func(Value, Type) Value { … } // makeInt returns a Value of type t equal to bits (possibly truncated), // where t is a signed or unsigned int type. func makeInt(f flag, bits uint64, t Type) Value { … } // makeFloat returns a Value of type t equal to v (possibly truncated to float32), // where t is a float32 or float64 type. func makeFloat(f flag, v float64, t Type) Value { … } // makeFloat32 returns a Value of type t equal to v, where t is a float32 type. func makeFloat32(f flag, v float32, t Type) Value { … } // makeComplex returns a Value of type t equal to v (possibly truncated to complex64), // where t is a complex64 or complex128 type. func makeComplex(f flag, v complex128, t Type) Value { … } func makeString(f flag, v string, t Type) Value { … } func makeBytes(f flag, v []byte, t Type) Value { … } func makeRunes(f flag, v []rune, t Type) Value { … } // convertOp: intXX -> [u]intXX func cvtInt(v Value, t Type) Value { … } // convertOp: uintXX -> [u]intXX func cvtUint(v Value, t Type) Value { … } // convertOp: floatXX -> intXX func cvtFloatInt(v Value, t Type) Value { … } // convertOp: floatXX -> uintXX func cvtFloatUint(v Value, t Type) Value { … } // convertOp: intXX -> floatXX func cvtIntFloat(v Value, t Type) Value { … } // convertOp: uintXX -> floatXX func cvtUintFloat(v Value, t Type) Value { … } // convertOp: floatXX -> floatXX func cvtFloat(v Value, t Type) Value { … } // convertOp: complexXX -> complexXX func cvtComplex(v Value, t Type) Value { … } // convertOp: intXX -> string func cvtIntString(v Value, t Type) Value { … } // convertOp: uintXX -> string func cvtUintString(v Value, t Type) Value { … } // convertOp: []byte -> string func cvtBytesString(v Value, t Type) Value { … } // convertOp: string -> []byte func cvtStringBytes(v Value, t Type) Value { … } // convertOp: []rune -> string func cvtRunesString(v Value, t Type) Value { … } // convertOp: string -> []rune func cvtStringRunes(v Value, t Type) Value { … } // convertOp: []T -> *[N]T func cvtSliceArrayPtr(v Value, t Type) Value { … } // convertOp: []T -> [N]T func cvtSliceArray(v Value, t Type) Value { … } // convertOp: direct copy func cvtDirect(v Value, typ Type) Value { … } // convertOp: concrete -> interface func cvtT2I(v Value, typ Type) Value { … } // convertOp: interface -> interface func cvtI2I(v Value, typ Type) Value { … } // implemented in ../runtime // //go:noescape func chancap(ch unsafe.Pointer) int //go:noescape func chanclose(ch unsafe.Pointer) //go:noescape func chanlen(ch unsafe.Pointer) int //go:noescape func chanrecv(ch unsafe.Pointer, nb bool, val unsafe.Pointer) (selected, received bool) //go:noescape func chansend0(ch unsafe.Pointer, val unsafe.Pointer, nb bool) bool func chansend(ch unsafe.Pointer, val unsafe.Pointer, nb bool) bool { … } func makechan(typ *abi.Type, size int) (ch unsafe.Pointer) func makemap(t *abi.Type, cap int) (m unsafe.Pointer) //go:noescape func mapaccess(t *abi.Type, m unsafe.Pointer, key unsafe.Pointer) (val unsafe.Pointer) //go:noescape func mapaccess_faststr(t *abi.Type, m unsafe.Pointer, key string) (val unsafe.Pointer) //go:noescape func mapassign0(t *abi.Type, m unsafe.Pointer, key, val unsafe.Pointer) // mapassign should be an internal detail, // but widely used packages access it using linkname. // Notable members of the hall of shame include: // - github.com/modern-go/reflect2 // - github.com/goccy/go-json // // Do not remove or change the type signature. // See go.dev/issue/67401. // //go:linkname mapassign func mapassign(t *abi.Type, m unsafe.Pointer, key, val unsafe.Pointer) { … } //go:noescape func mapassign_faststr0(t *abi.Type, m unsafe.Pointer, key string, val unsafe.Pointer) func mapassign_faststr(t *abi.Type, m unsafe.Pointer, key string, val unsafe.Pointer) { … } //go:noescape func mapdelete(t *abi.Type, m unsafe.Pointer, key unsafe.Pointer) //go:noescape func mapdelete_faststr(t *abi.Type, m unsafe.Pointer, key string) //go:noescape func mapiterinit(t *abi.Type, m unsafe.Pointer, it *hiter) //go:noescape func mapiternext(it *hiter) //go:noescape func maplen(m unsafe.Pointer) int func mapclear(t *abi.Type, m unsafe.Pointer) // call calls fn with "stackArgsSize" bytes of stack arguments laid out // at stackArgs and register arguments laid out in regArgs. frameSize is // the total amount of stack space that will be reserved by call, so this // should include enough space to spill register arguments to the stack in // case of preemption. // // After fn returns, call copies stackArgsSize-stackRetOffset result bytes // back into stackArgs+stackRetOffset before returning, for any return // values passed on the stack. Register-based return values will be found // in the same regArgs structure. // // regArgs must also be prepared with an appropriate ReturnIsPtr bitmap // indicating which registers will contain pointer-valued return values. The // purpose of this bitmap is to keep pointers visible to the GC between // returning from reflectcall and actually using them. // // If copying result bytes back from the stack, the caller must pass the // argument frame type as stackArgsType, so that call can execute appropriate // write barriers during the copy. // // Arguments passed through to call do not escape. The type is used only in a // very limited callee of call, the stackArgs are copied, and regArgs is only // used in the call frame. // //go:noescape //go:linkname call runtime.reflectcall func call(stackArgsType *abi.Type, f, stackArgs unsafe.Pointer, stackArgsSize, stackRetOffset, frameSize uint32, regArgs *abi.RegArgs) func ifaceE2I(t *abi.Type, src any, dst unsafe.Pointer) // memmove copies size bytes to dst from src. No write barriers are used. // //go:noescape func memmove(dst, src unsafe.Pointer, size uintptr) // typedmemmove copies a value of type t to dst from src. // //go:noescape func typedmemmove(t *abi.Type, dst, src unsafe.Pointer) // typedmemclr zeros the value at ptr of type t. // //go:noescape func typedmemclr(t *abi.Type, ptr unsafe.Pointer) // typedmemclrpartial is like typedmemclr but assumes that // dst points off bytes into the value and only clears size bytes. // //go:noescape func typedmemclrpartial(t *abi.Type, ptr unsafe.Pointer, off, size uintptr) // typedslicecopy copies a slice of elemType values from src to dst, // returning the number of elements copied. // //go:noescape func typedslicecopy(t *abi.Type, dst, src unsafeheader.Slice) int // typedarrayclear zeroes the value at ptr of an array of elemType, // only clears len elem. // //go:noescape func typedarrayclear(elemType *abi.Type, ptr unsafe.Pointer, len int) //go:noescape func typehash(t *abi.Type, p unsafe.Pointer, h uintptr) uintptr func verifyNotInHeapPtr(p uintptr) bool //go:noescape func growslice(t *abi.Type, old unsafeheader.Slice, num int) unsafeheader.Slice //go:noescape func unsafeslice(t *abi.Type, ptr unsafe.Pointer, len int) // Dummy annotation marking that the value x escapes, // for use in cases where the reflect code is so clever that // the compiler cannot follow. func escapes(x any) { … } var dummy … // Dummy annotation marking that the content of value x // escapes (i.e. modeling roughly heap=*x), // for use in cases where the reflect code is so clever that // the compiler cannot follow. func contentEscapes(x unsafe.Pointer) { … }