This is a creation in Article, where the information may have evolved or changed.
Functions in the Value.go
-
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 makeslice (Typ Type, len, Cap int) Value
-
Func New (Typ Type) Value
-
Func NewAt (Typ Type, p unsafe. Pointer) Value
-
Func ValueOf (i interface{}) Value
-
Func Zero (Typ Type) Value
Method of the value structure
-
-
ADDR () Value
-
-
typically used to get a pointer to a struct field or a slice element in order to call a method, the receiver is required.
-
-
BOOL () bool
-
-
returns the underlying value, which can cause panic if the kind of V is not bool
-
-
Bytes () []byte
-
-
returns the underlying value, which can cause panic if the underlying value of V is not a byte slice
B: = []byte{' A ', ' B '}fmt. Println (reflect. ValueOf (b). Bytes ())
-
-
CANADDR () bool
-
-
Check to see if V is addressable
-
-
Canset () bool
-
-
Check if the value can be set, only addressable can be set
B: = 555p:=reflect. ValueOf (&b) V: = P.elem () //Reflection object P is not addressable, but does not want to set P, (actually) is *p. To get the content that P points to, call the Elem method on the value, point indirectly from the pointer, and then save the result of the reflection value called VV. Setint (666) fmt. Println (b)
-
-
Call (in []value) []value
-
-
the value of the reflection function. and call
Func Test (a string) string {return A}func main () {a: = "sssssss" args: = []reflect. Value{reflect. ValueOf (a)}c: = reflect. ValueOf (Test). Call (args) fmt. Println (c)}
-
-
Callslice (in []value) []value
-
-
Ibid
.
-
-
Close ()
-
-
close the channel, and if it's not Chan, panic.
-
-
Complex () complex128
-
-
returns the underlying value, if the value is not a complex number, generates a panic
-
-
Elem () Value
-
-
returns the value contained in V, which is used for addressing operations when setting values
-
-
Field (i int) Value
-
-
returns the value of an indexed field in a structure
Type A struct {a intb Bytec String}func main () {a: = A{}fmt. Println (reflect. ValueOf (a). Field (0). Int ())}
-
-
Fieldbyindex (Index []int) Value
-
-
ditto, but. provided is a slice
-
-
Fieldbyname (name string) Value
-
-
Find By field name
-
-
Fieldbynamefunc (Match func (string) bool) Value
-
-
Find by Function name
-
-
Float () float64
-
-
returns the underlying value, if the value is not a float, generates a panic
-
-
Index (i int) Value
-
-
If kind is not an array or sliece, the poor student panics and returns the element as value
-
-
Int () Int64
-
-
returns the underlying value, if the value is not an int, generates a panic
-
-
Caninterface () bool
-
-
returns True if the interface can be used
-
-
Interface () (I interface{})
-
-
returns the current value of V as interface{}
-
-
Interfacedata () [2]uintptr
-
-
If kind is not an interface, it can cause panic
.
-
-
Isnil () bool
-
-
returns True if V is a nil
-
-
IsValid () bool
-
-
returns True if V represents a value
-
-
Kind () Kind
-
-
returns the type of V
-
-
Len () int
-
-
returns the length of V
-
-
Mapindex (key value) value
-
-
if it is a map, the value whose key value is reflected by key
-
-
Mapkeys () []value
-
-
return all keys of map
-
-
Method (i int) Value
-
-
reflect structure values of a method by index
-
-
Nummethod () int
-
-
number of statistical structural methods
-
-
Methodbyname (name string) Value
-
-
the value of the reflection method is based on the method name
-
-
Numfield () int
-
-
number of fields reflecting a structure
-
-
Overflowcomplex (x complex128) bool
-
-
covering complex numbers
-
-
Overflowfloat (x float64) bool
-
-
overriding floating-point numbers
-
-
OverflowFloat32 (x float64) bool
-
-
-
Overflowint (x Int64) bool
-
-
-
Overflowuint (x UInt64) bool
-
-
-
Pointer () uintptr
-
-
reflects the value of a pointer. Returns the integer value of a pointer
-
-
RECV () (x Value, OK bool)
-
-
for Channel
-
-
Send (x Value)
-
-
for Channel
-
-
Set (x Value)
-
-
if v can be set, set a value of V
-
-
Setbool (x bool)
-
-
if v can be set and is bool, set a value of V
-
-
SetBytes (x []byte)
-
-
-
Setcomplex (x complex128)
-
-
-
SetFloat (x float64)
-
-
-
Setint (x Int64)
-
-
-
Setlen (n int)
-
-
-
Setmapindex (Key, Val Value)
-
-
-
Setuint (x UInt64)
-
-
-
Setpointer (x unsafe. Pointer)
-
-
-
SetString (x String)
-
-
-
Slice (Beg, end int) Value
-
-
The return value if the underlying is slice.
-
-
String () string
-
-
if Dicheng is a character channeling, the return character is
-
-
TRYRECV () (x Value, OK bool)
-
-
for Channel, accept
-
-
Trysend (x Value) bool
-
-
for channel, send
-
-
Type () type
-
-
return type
-
-
Uint () UInt64
-
-
If the Dicheng is a uint, the uint is returned.
-
-
UNSAFEADDR () uintptr