Go Home Page
The Go Programming Language

Package reflect

import "reflect"

The reflect package 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 an object with interface type Type. That contains a pointer to a struct of type *StructType, *IntType, etc. representing the details of the underlying type. A type switch or type assertion can reveal which.

A call to NewValue creates a Value representing the run-time data; it contains a *StructValue, *IntValue, etc. MakeZero takes a Type and returns a Value representing a zero value for that type.

Package files

deepequal.go type.go value.go

func ArrayCopy

func ArrayCopy(dst, src ArrayOrSliceValue) int

ArrayCopy 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. The arrays dst and src must have the same element type.

func DeepEqual

func DeepEqual(a1, a2 interface{}) bool

DeepEqual tests for deep equality. It uses normal == equality where possible but will scan members of arrays, slices, and fields of structs. It correctly handles recursive types.

type ArrayOrSliceType

ArrayOrSliceType is the common interface implemented by both ArrayType and SliceType.

type ArrayOrSliceType interface {
    Type
    Elem() Type
}

type ArrayOrSliceValue

ArrayOrSliceValue is the common interface implemented by both ArrayValue and SliceValue.

type ArrayOrSliceValue interface {
    Value
    Len() int
    Cap() int
    Elem(i int) Value
    // contains unexported methods
}

type ArrayType

ArrayType represents a fixed array type.

type ArrayType struct {
    // contains unexported fields
}

func (*ArrayType) Elem

func (t *ArrayType) Elem() Type

Elem returns the type of the array's elements.

func (*ArrayType) Len

func (t *ArrayType) Len() int

Len returns the number of elements in the array.

type ArrayValue

An ArrayValue represents an array.

type ArrayValue struct {
    // contains unexported fields
}

func (*ArrayValue) Cap

func (v *ArrayValue) Cap() int

Cap returns the capacity of the array (equal to Len()).

func (*ArrayValue) Elem

func (v *ArrayValue) Elem(i int) Value

Elem returns the i'th element of v.

func (*ArrayValue) Len

func (v *ArrayValue) Len() int

Len returns the length of the array.

func (*ArrayValue) Set

func (v *ArrayValue) Set(x *ArrayValue)

Set assigns x to v. The new value x must have the same type as v.

func (*ArrayValue) SetValue

func (v *ArrayValue) SetValue(x Value)

Set sets v to the value x.

type BoolType

BoolType represents a boolean type.

type BoolType struct {
    // contains unexported fields
}

type BoolValue

BoolValue represents a bool value.

type BoolValue struct {
    // contains unexported fields
}

func (*BoolValue) Get

func (v *BoolValue) Get() bool

Get returns the underlying bool value.

func (*BoolValue) Set

func (v *BoolValue) Set(x bool)

Set sets v to the value x.

func (*BoolValue) SetValue

func (v *BoolValue) SetValue(x Value)

Set sets v to the value x.

type ChanDir

ChanDir represents a channel type's direction.

type ChanDir int

const (
    RecvDir ChanDir = 1 << iota
    SendDir
    BothDir = RecvDir | SendDir
)

func (ChanDir) String

func (d ChanDir) String() string

type ChanType

ChanType represents a channel type.

type ChanType struct {
    // contains unexported fields
}

func (*ChanType) Dir

func (t *ChanType) Dir() ChanDir

Dir returns the channel direction.

func (*ChanType) Elem

func (t *ChanType) Elem() Type

Elem returns the channel's element type.

type ChanValue

A ChanValue represents a chan.

type ChanValue struct {
    // contains unexported fields
}

func MakeChan

func MakeChan(typ *ChanType, buffer int) *ChanValue

MakeChan creates a new channel with the specified type and buffer size.

func (*ChanValue) Cap

func (v *ChanValue) Cap() int

func (*ChanValue) Close

func (v *ChanValue) Close()

Close closes the channel.

func (*ChanValue) Closed

func (v *ChanValue) Closed() bool

Closed returns the result of closed(c) on the underlying channel.

func (*ChanValue) Get

func (v *ChanValue) Get() uintptr

Get returns the uintptr value of v. It is mainly useful for printing.

func (*ChanValue) IsNil

func (v *ChanValue) IsNil() bool

IsNil returns whether v is a nil channel.

func (*ChanValue) Len

func (v *ChanValue) Len() int

func (*ChanValue) Recv

func (v *ChanValue) Recv() Value

Recv receives and returns a value from the channel v.

func (*ChanValue) Send

func (v *ChanValue) Send(x Value)

Send sends x on the channel v.

func (*ChanValue) Set

func (v *ChanValue) Set(x *ChanValue)

Set assigns x to v. The new value x must have the same type as v.

func (*ChanValue) SetValue

func (v *ChanValue) SetValue(x Value)

Set sets v to the value x.

func (*ChanValue) TryRecv

func (v *ChanValue) TryRecv() Value

TryRecv attempts to receive a value from the channel v but will not block. It returns the value if one is received, nil otherwise.

func (*ChanValue) TrySend

func (v *ChanValue) TrySend(x Value) bool

TrySend attempts to sends x on the channel v but will not block. It returns true if the value was sent, false otherwise.

type Float32Type

Float32Type represents a float32 type.

type Float32Type struct {
    // contains unexported fields
}

type Float32Value

Float32Value represents a float32 value.

type Float32Value struct {
    // contains unexported fields
}

func (*Float32Value) Get

func (v *Float32Value) Get() float32

Get returns the underlying float32 value.

func (*Float32Value) Set

func (v *Float32Value) Set(x float32)

Set sets v to the value x.

func (*Float32Value) SetValue

func (v *Float32Value) SetValue(x Value)

Set sets v to the value x.

type Float64Type

Float64Type represents a float64 type.

type Float64Type struct {
    // contains unexported fields
}

type Float64Value

Float64Value represents a float64 value.

type Float64Value struct {
    // contains unexported fields
}

func (*Float64Value) Get

func (v *Float64Value) Get() float64

Get returns the underlying float64 value.

func (*Float64Value) Set

func (v *Float64Value) Set(x float64)

Set sets v to the value x.

func (*Float64Value) SetValue

func (v *Float64Value) SetValue(x Value)

Set sets v to the value x.

type FloatType

FloatType represents a float type.

type FloatType struct {
    // contains unexported fields
}

type FloatValue

FloatValue represents a float value.

type FloatValue struct {
    // contains unexported fields
}

func (*FloatValue) Get

func (v *FloatValue) Get() float

Get returns the underlying float value.

func (*FloatValue) Set

func (v *FloatValue) Set(x float)

Set sets v to the value x.

func (*FloatValue) SetValue

func (v *FloatValue) SetValue(x Value)

Set sets v to the value x.

type FuncType

FuncType represents a function type.

type FuncType struct {
    // contains unexported fields
}

func (*FuncType) DotDotDot

func (t *FuncType) DotDotDot() bool

DotDotDot returns true if the final function input parameter is a "..." parameter. If so, the parameter's underlying static type - either interface{} or []T - is returned by t.In(t.NumIn() - 1).

For concreteness, if t is func(x int, y ... float), then

t.NumIn() == 2
t.In(0) is the reflect.Type for "int"
t.In(1) is the reflect.Type for "[]float"
t.DotDotDot() == true

func (*FuncType) In

func (t *FuncType) In(i int) Type

In returns the type of the i'th function input parameter.

func (*FuncType) NumIn

func (t *FuncType) NumIn() int

NumIn returns the number of input parameters.

func (*FuncType) NumOut

func (t *FuncType) NumOut() int

NumOut returns the number of function output parameters.

func (*FuncType) Out

func (t *FuncType) Out(i int) Type

Out returns the type of the i'th function output parameter.

type FuncValue

A FuncValue represents a function value.

type FuncValue struct {
    // contains unexported fields
}

func (*FuncValue) Call

func (fv *FuncValue) Call(in []Value) []Value

Call calls the function v with input parameters in. It returns the function's output parameters as Values.

func (*FuncValue) Get

func (v *FuncValue) Get() uintptr

Get returns the uintptr value of v. It is mainly useful for printing.

func (*FuncValue) IsNil

func (v *FuncValue) IsNil() bool

IsNil returns whether v is a nil function.

func (*FuncValue) Set

func (v *FuncValue) Set(x *FuncValue)

Set assigns x to v. The new value x must have the same type as v.

func (*FuncValue) SetValue

func (v *FuncValue) SetValue(x Value)

Set sets v to the value x.

type Int16Type

Int16Type represents an int16 type.

type Int16Type struct {
    // contains unexported fields
}

type Int16Value

Int16Value represents an int16 value.

type Int16Value struct {
    // contains unexported fields
}

func (*Int16Value) Get

func (v *Int16Value) Get() int16

Get returns the underlying int16 value.

func (*Int16Value) Set

func (v *Int16Value) Set(x int16)

Set sets v to the value x.

func (*Int16Value) SetValue

func (v *Int16Value) SetValue(x Value)

Set sets v to the value x.

type Int32Type

Int32Type represents an int32 type.

type Int32Type struct {
    // contains unexported fields
}

type Int32Value

Int32Value represents an int32 value.

type Int32Value struct {
    // contains unexported fields
}

func (*Int32Value) Get

func (v *Int32Value) Get() int32

Get returns the underlying int32 value.

func (*Int32Value) Set

func (v *Int32Value) Set(x int32)

Set sets v to the value x.

func (*Int32Value) SetValue

func (v *Int32Value) SetValue(x Value)

Set sets v to the value x.

type Int64Type

Int64Type represents an int64 type.

type Int64Type struct {
    // contains unexported fields
}

type Int64Value

Int64Value represents an int64 value.

type Int64Value struct {
    // contains unexported fields
}

func (*Int64Value) Get

func (v *Int64Value) Get() int64

Get returns the underlying int64 value.

func (*Int64Value) Set

func (v *Int64Value) Set(x int64)

Set sets v to the value x.

func (*Int64Value) SetValue

func (v *Int64Value) SetValue(x Value)

Set sets v to the value x.

type Int8Type

Int8Type represents an int8 type.

type Int8Type struct {
    // contains unexported fields
}

type Int8Value

Int8Value represents an int8 value.

type Int8Value struct {
    // contains unexported fields
}

func (*Int8Value) Get

func (v *Int8Value) Get() int8

Get returns the underlying int8 value.

func (*Int8Value) Set

func (v *Int8Value) Set(x int8)

Set sets v to the value x.

func (*Int8Value) SetValue

func (v *Int8Value) SetValue(x Value)

Set sets v to the value x.

type IntType

IntType represents an int type.

type IntType struct {
    // contains unexported fields
}

type IntValue

IntValue represents an int value.

type IntValue struct {
    // contains unexported fields
}

func (*IntValue) Get

func (v *IntValue) Get() int

Get returns the underlying int value.

func (*IntValue) Set

func (v *IntValue) Set(x int)

Set sets v to the value x.

func (*IntValue) SetValue

func (v *IntValue) SetValue(x Value)

Set sets v to the value x.

type InterfaceType

InterfaceType represents an interface type.

type InterfaceType struct {
    // contains unexported fields
}

func (*InterfaceType) Method

func (t *InterfaceType) Method(i int) (m Method)

Method returns the i'th interface method.

func (*InterfaceType) NumMethod

func (t *InterfaceType) NumMethod() int

NumMethod returns the number of interface methods.

type InterfaceValue

An InterfaceValue represents an interface value.

type InterfaceValue struct {
    // contains unexported fields
}

func (*InterfaceValue) Elem

func (v *InterfaceValue) Elem() Value

Elem returns the concrete value stored in the interface value v.

func (*InterfaceValue) IsNil

func (v *InterfaceValue) IsNil() bool

IsNil returns whether v is a nil interface value.

func (*InterfaceValue) Method

func (v *InterfaceValue) Method(i int) *FuncValue

Method returns a FuncValue corresponding to v's i'th method. The arguments to a Call on the returned FuncValue should not include a receiver; the FuncValue will use v as the receiver.

func (*InterfaceValue) Set

func (v *InterfaceValue) Set(x Value)

Set assigns x to v.

func (*InterfaceValue) SetValue

func (v *InterfaceValue) SetValue(x Value)

Set sets v to the value x.

type MapType

MapType represents a map type.

type MapType struct {
    // contains unexported fields
}

func (*MapType) Elem

func (t *MapType) Elem() Type

Elem returns the map element type.

func (*MapType) Key

func (t *MapType) Key() Type

Key returns the map key type.

type MapValue

A MapValue represents a map value.

type MapValue struct {
    // contains unexported fields
}

func MakeMap

func MakeMap(typ *MapType) *MapValue

MakeMap creates a new map of the specified type.

func (*MapValue) Elem

func (v *MapValue) Elem(key Value) Value

Elem returns the value associated with key in the map v. It returns nil if key is not found in the map.

func (*MapValue) Get

func (v *MapValue) Get() uintptr

Get returns the uintptr value of v. It is mainly useful for printing.

func (*MapValue) IsNil

func (v *MapValue) IsNil() bool

IsNil returns whether v is a nil map value.

func (*MapValue) Keys

func (v *MapValue) Keys() []Value

Keys returns a slice containing all the keys present in the map, in unspecified order.

func (*MapValue) Len

func (v *MapValue) Len() int

Len returns the number of keys in the map v.

func (*MapValue) Set

func (v *MapValue) Set(x *MapValue)

Set assigns x to v. The new value x must have the same type as v.

func (*MapValue) SetElem

func (v *MapValue) SetElem(key, val Value)

SetElem sets the value associated with key in the map v to val. If val is nil, Put deletes the key from map.

func (*MapValue) SetValue

func (v *MapValue) SetValue(x Value)

Set sets v to the value x.

type Method

Method represents a single method.

type Method struct {
    PkgPath string // empty for uppercase Name
    Name    string
    Type    *FuncType
    Func    *FuncValue
}

type PtrType

PtrType represents a pointer type.

type PtrType struct {
    // contains unexported fields
}

func (*PtrType) Elem

func (t *PtrType) Elem() Type

Elem returns the pointer element type.

type PtrValue

A PtrValue represents a pointer.

type PtrValue struct {
    // contains unexported fields
}

func (*PtrValue) Elem

func (v *PtrValue) Elem() Value

Elem returns the value that v points to. If v is a nil pointer, Elem returns a nil Value.

func (*PtrValue) Get

func (v *PtrValue) Get() uintptr

Get returns the uintptr value of v. It is mainly useful for printing.

func (*PtrValue) IsNil

func (v *PtrValue) IsNil() bool

IsNil returns whether v is a nil pointer.

func (*PtrValue) PointTo

func (v *PtrValue) PointTo(x Value)

PointTo changes v to point to x.

func (*PtrValue) Set

func (v *PtrValue) Set(x *PtrValue)

Set assigns x to v. The new value x must have the same type as v.

func (*PtrValue) SetValue

func (v *PtrValue) SetValue(x Value)

Set sets v to the value x.

type SliceHeader

runtime representation of slice

type SliceHeader struct {
    Data uintptr
    Len  int
    Cap  int
}

type SliceType

SliceType represents a slice type.

type SliceType struct {
    // contains unexported fields
}

func (*SliceType) Elem

func (t *SliceType) Elem() Type

Elem returns the type of the slice's elements.

type SliceValue

A SliceValue represents a slice.

type SliceValue struct {
    // contains unexported fields
}

func MakeSlice

func MakeSlice(typ *SliceType, len, cap int) *SliceValue

MakeSlice creates a new zero-initialized slice value for the specified slice type, length, and capacity.

func (*SliceValue) Cap

func (v *SliceValue) Cap() int

Cap returns the capacity of the slice.

func (*SliceValue) Elem

func (v *SliceValue) Elem(i int) Value

Elem returns the i'th element of v.

func (*SliceValue) Get

func (v *SliceValue) Get() uintptr

Get returns the uintptr address of the v.Cap()'th element. This gives the same result for all slices of the same array. It is mainly useful for printing.

func (*SliceValue) IsNil

func (v *SliceValue) IsNil() bool

IsNil returns whether v is a nil slice.

func (*SliceValue) Len

func (v *SliceValue) Len() int

Len returns the length of the slice.

func (*SliceValue) Set

func (v *SliceValue) Set(x *SliceValue)

Set assigns x to v. The new value x must have the same type as v.

func (*SliceValue) SetLen

func (v *SliceValue) SetLen(n int)

SetLen changes the length of v. The new length n must be between 0 and the capacity, inclusive.

func (*SliceValue) SetValue

func (v *SliceValue) SetValue(x Value)

Set sets v to the value x.

func (*SliceValue) Slice

func (v *SliceValue) Slice(beg, end int) *SliceValue

Slice returns a sub-slice of the slice v.

type StringHeader

StringHeader is the runtime representation of a string.

type StringHeader struct {
    Data uintptr
    Len  int
}

type StringType

StringType represents a string type.

type StringType struct {
    // contains unexported fields
}

type StringValue

StringValue represents a string value.

type StringValue struct {
    // contains unexported fields
}

func (*StringValue) Get

func (v *StringValue) Get() string

Get returns the underlying string value.

func (*StringValue) Set

func (v *StringValue) Set(x string)

Set sets v to the value x.

func (*StringValue) SetValue

func (v *StringValue) SetValue(x Value)

Set sets v to the value x.

type StructField

type StructField struct {
    PkgPath   string // empty for uppercase Name
    Name      string
    Type      Type
    Tag       string
    Offset    uintptr
    Index     []int
    Anonymous bool
}

type StructType

StructType represents a struct type.

type StructType struct {
    // contains unexported fields
}

func (*StructType) Field

func (t *StructType) Field(i int) (f StructField)

Field returns the i'th struct field.

func (*StructType) FieldByIndex

func (t *StructType) FieldByIndex(index []int) (f StructField)

FieldByIndex returns the nested field corresponding to index.

func (*StructType) FieldByName

func (t *StructType) FieldByName(name string) (f StructField, present bool)

FieldByName returns the struct field with the given name and a boolean to indicate if the field was found.

func (*StructType) NumField

func (t *StructType) NumField() int

NumField returns the number of struct fields.

type StructValue

A StructValue represents a struct value.

type StructValue struct {
    // contains unexported fields
}

func (*StructValue) Field

func (v *StructValue) Field(i int) Value

Field returns the i'th field of the struct.

func (*StructValue) FieldByIndex

func (t *StructValue) FieldByIndex(index []int) (v Value)

FieldByIndex returns the nested field corresponding to index.

func (*StructValue) FieldByName

func (t *StructValue) FieldByName(name string) Value

FieldByName returns the struct field with the given name. The result is nil if no field was found.

func (*StructValue) NumField

func (v *StructValue) NumField() int

NumField returns the number of fields in the struct.

func (*StructValue) Set

func (v *StructValue) Set(x *StructValue)

Set assigns x to v. The new value x must have the same type as v.

func (*StructValue) SetValue

func (v *StructValue) SetValue(x Value)

Set sets v to the value x.

type Type

Type is the runtime representation of a Go type. Every type implements the methods listed here. Some types implement additional interfaces; use a type switch to find out what kind of type a Type is. Each type in a program has a unique Type, so == on Types corresponds to Go's type equality.

type Type interface {
    // PkgPath returns the type's package path.
    // The package path is a full package import path like "container/vector".
    // PkgPath returns an empty string for unnamed types.
    PkgPath() string

    // Name returns the type's name within its package.
    // Name returns an empty string for unnamed types.
    Name() string

    // String returns a string representation of the type.
    // The string representation may use shortened package names
    // (e.g., vector instead of "container/vector") and is not
    // guaranteed to be unique among types.  To test for equality,
    // compare the Types directly.
    String() string

    // Size returns the number of bytes needed to store
    // a value of the given type; it is analogous to unsafe.Sizeof.
    Size() uintptr

    // Align returns the alignment of a value of this type
    // when allocated in memory.
    Align() int

    // FieldAlign returns the alignment of a value of this type
    // when used as a field in a struct.
    FieldAlign() int

    // For non-interface types, Method returns the i'th method with receiver T.
    // For interface types, Method returns the i'th method in the interface.
    // NumMethod returns the number of such methods.
    Method(int) Method
    NumMethod() int
    // contains unexported methods
}

func Typeof

func Typeof(i interface{}) Type

Typeof returns the reflection Type of the value in the interface{}.

type Uint16Type

Uint16Type represents a uint16 type.

type Uint16Type struct {
    // contains unexported fields
}

type Uint16Value

Uint16Value represents a uint16 value.

type Uint16Value struct {
    // contains unexported fields
}

func (*Uint16Value) Get

func (v *Uint16Value) Get() uint16

Get returns the underlying uint16 value.

func (*Uint16Value) Set

func (v *Uint16Value) Set(x uint16)

Set sets v to the value x.

func (*Uint16Value) SetValue

func (v *Uint16Value) SetValue(x Value)

Set sets v to the value x.

type Uint32Type

Uint32Type represents a uint32 type.

type Uint32Type struct {
    // contains unexported fields
}

type Uint32Value

Uint32Value represents a uint32 value.

type Uint32Value struct {
    // contains unexported fields
}

func (*Uint32Value) Get

func (v *Uint32Value) Get() uint32

Get returns the underlying uint32 value.

func (*Uint32Value) Set

func (v *Uint32Value) Set(x uint32)

Set sets v to the value x.

func (*Uint32Value) SetValue

func (v *Uint32Value) SetValue(x Value)

Set sets v to the value x.

type Uint64Type

Uint64Type represents a uint64 type.

type Uint64Type struct {
    // contains unexported fields
}

type Uint64Value

Uint64Value represents a uint64 value.

type Uint64Value struct {
    // contains unexported fields
}

func (*Uint64Value) Get

func (v *Uint64Value) Get() uint64

Get returns the underlying uint64 value.

func (*Uint64Value) Set

func (v *Uint64Value) Set(x uint64)

Set sets v to the value x.

func (*Uint64Value) SetValue

func (v *Uint64Value) SetValue(x Value)

Set sets v to the value x.

type Uint8Type

Uint8Type represents a uint8 type.

type Uint8Type struct {
    // contains unexported fields
}

type Uint8Value

Uint8Value represents a uint8 value.

type Uint8Value struct {
    // contains unexported fields
}

func (*Uint8Value) Get

func (v *Uint8Value) Get() uint8

Get returns the underlying uint8 value.

func (*Uint8Value) Set

func (v *Uint8Value) Set(x uint8)

Set sets v to the value x.

func (*Uint8Value) SetValue

func (v *Uint8Value) SetValue(x Value)

Set sets v to the value x.

type UintType

UintType represents a uint type.

type UintType struct {
    // contains unexported fields
}

type UintValue

UintValue represents a uint value.

type UintValue struct {
    // contains unexported fields
}

func (*UintValue) Get

func (v *UintValue) Get() uint

Get returns the underlying uint value.

func (*UintValue) Set

func (v *UintValue) Set(x uint)

Set sets v to the value x.

func (*UintValue) SetValue

func (v *UintValue) SetValue(x Value)

Set sets v to the value x.

type UintptrType

UintptrType represents a uintptr type.

type UintptrType struct {
    // contains unexported fields
}

type UintptrValue

UintptrValue represents a uintptr value.

type UintptrValue struct {
    // contains unexported fields
}

func (*UintptrValue) Get

func (v *UintptrValue) Get() uintptr

Get returns the underlying uintptr value.

func (*UintptrValue) Set

func (v *UintptrValue) Set(x uintptr)

Set sets v to the value x.

func (*UintptrValue) SetValue

func (v *UintptrValue) SetValue(x Value)

Set sets v to the value x.

type UnsafePointerType

UnsafePointerType represents an unsafe.Pointer type.

type UnsafePointerType struct {
    // contains unexported fields
}

type UnsafePointerValue

UnsafePointerValue represents an unsafe.Pointer value.

type UnsafePointerValue struct {
    // contains unexported fields
}

func (*UnsafePointerValue) Get

func (v *UnsafePointerValue) Get() uintptr

Get returns the underlying uintptr value. Get returns uintptr, not unsafe.Pointer, so that programs that do not import "unsafe" cannot obtain a value of unsafe.Pointer type from "reflect".

func (*UnsafePointerValue) Set

func (v *UnsafePointerValue) Set(x unsafe.Pointer)

Set sets v to the value x.

func (*UnsafePointerValue) SetValue

func (v *UnsafePointerValue) SetValue(x Value)

Set sets v to the value x.

type Value

Value is the common interface to reflection values. The implementations of Value (e.g., ArrayValue, StructValue) have additional type-specific methods.

type Value interface {
    // Type returns the value's type.
    Type() Type

    // Interface returns the value as an interface{}.
    Interface() interface{}

    // CanSet returns whether the value can be changed.
    // Values obtained by the use of non-exported struct fields
    // can be used in Get but not Set.
    // If CanSet() returns false, calling the type-specific Set
    // will cause a crash.
    CanSet() bool

    // SetValue assigns v to the value; v must have the same type as the value.
    SetValue(v Value)

    // Addr returns a pointer to the underlying data.
    // It is for advanced clients that also
    // import the "unsafe" package.
    Addr() uintptr

    // Method returns a FuncValue corresponding to the value's i'th method.
    // The arguments to a Call on the returned FuncValue
    // should not include a receiver; the FuncValue will use
    // the value as the receiver.
    Method(i int) *FuncValue
    // contains unexported methods
}

func Indirect

func Indirect(v Value) Value

Indirect returns the value that v points to. If v is a nil pointer, Indirect returns a nil Value. If v is not a pointer, Indirect returns v.

func MakeZero

func MakeZero(typ Type) Value

MakeZero returns a zero Value for the specified Type.

func NewValue

func NewValue(i interface{}) Value

NewValue returns a new Value initialized to the concrete value stored in the interface i. NewValue(nil) returns nil.