Documentation ¶
Index ¶
- func Copy(dst, src Value) int
- func DeepEqual(x, y interface{}) bool
- func Swapper(slice interface{}) func(i, j int)
- type Kind
- type MapIter
- type SliceHeader
- type StringHeader
- type StructField
- type StructTag
- type Type
- type TypeError
- type Value
- func Append(s Value, x ...Value) Value
- func AppendSlice(s, t Value) Value
- func Indirect(v Value) 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 ValueOf(i interface{}) 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) CanAddr() bool
- func (v Value) CanInterface() bool
- func (v Value) CanSet() bool
- func (v Value) Cap() int
- func (v Value) Complex() complex128
- func (v Value) Convert(t Type) Value
- func (v Value) Elem() Value
- func (v Value) Field(i int) Value
- func (v Value) FieldByIndex(index []int) Value
- func (v Value) FieldByName(name string) Value
- func (v Value) Float() float64
- func (v Value) Index(i int) Value
- func (v Value) Int() int64
- func (v Value) Interface() interface{}
- func (v Value) IsNil() bool
- func (v Value) IsValid() 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) NumField() int
- func (v Value) NumMethod() int
- 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) RawType() rawType
- func (v Value) Set(x Value)
- func (v Value) SetBool(x bool)
- func (v Value) SetBytes(x []byte)
- func (v Value) SetCap(n int)
- func (v Value) SetComplex(x complex128)
- func (v Value) SetFloat(x float64)
- func (v Value) SetInt(x int64)
- func (v Value) SetLen(n int)
- func (v Value) SetMapIndex(key, elem Value)
- func (v Value) SetString(x string)
- func (v Value) SetUint(x uint64)
- func (v Value) Slice(i, j int) Value
- func (v Value) String() string
- func (v Value) Type() Type
- func (v Value) Uint() uint64
- type ValueError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Kind ¶
type Kind uintptr
const ( Invalid Kind = iota Bool Int Int8 Int16 Int32 Int64 Uint Uint8 Uint16 Uint32 Uint64 Uintptr Float32 Float64 Complex64 Complex128 String UnsafePointer Chan Interface Ptr Slice Array Func Map Struct )
Copied from reflect/type.go https://golang.org/src/reflect/type.go?s=8302:8316#L217
type SliceHeader ¶
type StringHeader ¶
type StructField ¶
type StructField struct { // Name indicates the field name. Name string // PkgPath is the package path where the struct containing this field is // declared for unexported fields, or the empty string for exported fields. PkgPath string Type Type Tag StructTag // field tag string Anonymous bool Offset uintptr }
A StructField describes a single field in a struct.
type StructTag ¶
type StructTag string
A StructTag is the tag string in a struct field.
type Type ¶
type Type interface { // Align returns the alignment in bytes of a value of // this type when allocated in memory. Align() int // FieldAlign returns the alignment in bytes of a value of // this type when used as a field in a struct. FieldAlign() int // NumMethod returns the number of exported methods in the type's method set. NumMethod() int // Name returns the type's name within its package for a defined type. // For other (non-defined) types it returns the empty string. Name() string // Size returns the number of bytes needed to store // a value of the given type; it is analogous to unsafe.Sizeof. Size() uintptr // String returns a string representation of the type. // The string representation may use shortened package names // (e.g., base64 instead of "encoding/base64") and is not // guaranteed to be unique among types. To test for type identity, // compare the Types directly. String() string // Kind returns the specific kind of this type. Kind() Kind // Implements reports whether the type implements the interface type u. Implements(u Type) bool // AssignableTo reports whether a value of the type is assignable to type u. AssignableTo(u Type) bool // ConvertibleTo reports whether a value of the type is convertible to type u. ConvertibleTo(u Type) bool // Comparable reports whether values of this type are comparable. Comparable() bool // Bits returns the size of the type in bits. // It panics if the type's Kind is not one of the // sized or unsized Int, Uint, Float, or Complex kinds. Bits() int // Elem returns a type's element type. // It panics if the type's Kind is not Array, Chan, Map, Ptr, or Slice. Elem() Type // Field returns a struct type's i'th field. // It panics if the type's Kind is not Struct. // It panics if i is not in the range [0, NumField()). Field(i int) StructField // Key returns a map type's key type. // It panics if the type's Kind is not Map. Key() Type // Len returns an array type's length. // It panics if the type's Kind is not Array. Len() int // NumField returns a struct type's field count. // It panics if the type's Kind is not Struct. NumField() int }
Type is the representation of a Go type.
Not all methods apply to all kinds of types. Restrictions, if any, are noted in the documentation for each method. Use the Kind method to find out the kind of type before calling kind-specific methods. Calling a method inappropriate to the kind of type causes a run-time panic.
Type values are comparable, such as with the == operator, so they can be used as map keys. Two Type values are equal if they represent identical types.
type TypeError ¶
type TypeError struct {
Method string
}
TypeError is the error that is used in a panic when invoking a method on a type that is not applicable to that type.
type Value ¶
type Value struct {
// contains filtered or unexported fields
}
func Append ¶
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 AppendSlice ¶
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 New ¶
New is the reflect equivalent of the new(T) keyword, returning a pointer to a new value of the given type.
func (Value) CanInterface ¶
func (Value) Cap ¶
Cap returns the capacity of this value for arrays, channels and slices. For other types, it panics.
func (Value) Complex ¶
func (v Value) Complex() complex128
func (Value) FieldByIndex ¶
FieldByIndex returns the nested field corresponding to index.
func (Value) FieldByName ¶
func (Value) IsNil ¶
IsNil returns whether the value is the nil value. It panics if the value Kind is not a channel, map, pointer, function, slice, or interface.
func (Value) Len ¶
Len returns the length of this value for slices, strings, arrays, channels, and maps. For other types, it panics.
func (Value) NumField ¶
NumField returns the number of fields of this struct. It panics for other value types.
func (Value) OverflowFloat ¶
func (Value) OverflowInt ¶
func (Value) OverflowUint ¶
func (Value) Pointer ¶
Pointer returns the underlying pointer of the given value for the following types: chan, map, pointer, unsafe.Pointer, slice, func.
func (Value) RawType ¶
func (v Value) RawType() rawType
Internal function only, do not use.
RawType returns the raw, underlying type code. It is used in the runtime package and needs to be exported for the runtime package to access it.
func (Value) SetComplex ¶
func (v Value) SetComplex(x complex128)
func (Value) SetMapIndex ¶
type ValueError ¶
type ValueError struct {
Method string
}
func (*ValueError) Error ¶
func (e *ValueError) Error() string