Documentation
¶
Index ¶
- func Addr(src interface{}) unsafe.Pointer
- func Register(aType reflect.Type, getter Getter)
- type Field
- func (f *Field) Addr(structAddr unsafe.Pointer) interface{}
- func (f *Field) AddrGetter() Getter
- func (f *Field) Bool(structAddr unsafe.Pointer) bool
- func (f *Field) BoolAddr(structAddr unsafe.Pointer) *bool
- func (f *Field) BoolPtr(structAddr unsafe.Pointer) *bool
- func (f *Field) Bytes(structAddr unsafe.Pointer) []byte
- func (f *Field) BytesAddr(structAddr unsafe.Pointer) *[]byte
- func (f *Field) BytesPtr(structAddr unsafe.Pointer) *[]byte
- func (f *Field) Float32(structAddr unsafe.Pointer) float32
- func (f *Field) Float32Addr(structAddr unsafe.Pointer) *float32
- func (f *Field) Float32Ptr(structAddr unsafe.Pointer) *float32
- func (f *Field) Float64(structAddr unsafe.Pointer) float64
- func (f *Field) Float64Addr(structAddr unsafe.Pointer) *float64
- func (f *Field) Float64Ptr(structAddr unsafe.Pointer) *float64
- func (f *Field) Int(structAddr unsafe.Pointer) int
- func (f *Field) Int16(structAddr unsafe.Pointer) int16
- func (f *Field) Int16Addr(structAddr unsafe.Pointer) *int16
- func (f *Field) Int16Ptr(structAddr unsafe.Pointer) *int16
- func (f *Field) Int32(structAddr unsafe.Pointer) int32
- func (f *Field) Int32Addr(structAddr unsafe.Pointer) *int32
- func (f *Field) Int32Ptr(structAddr unsafe.Pointer) *int32
- func (f *Field) Int64(structAddr unsafe.Pointer) int64
- func (f *Field) Int64Addr(structAddr unsafe.Pointer) *int64
- func (f *Field) Int64Ptr(structAddr unsafe.Pointer) *int64
- func (f *Field) Int8(structAddr unsafe.Pointer) int8
- func (f *Field) Int8Addr(structAddr unsafe.Pointer) *int8
- func (f *Field) Int8Ptr(structAddr unsafe.Pointer) *int8
- func (f *Field) IntAddr(structAddr unsafe.Pointer) *int
- func (f *Field) IntPtr(structAddr unsafe.Pointer) *int
- func (f *Field) Interface(structAddr unsafe.Pointer) interface{}
- func (f *Field) SetBool(structAddr unsafe.Pointer, val bool)
- func (f *Field) SetBoolPtr(structAddr unsafe.Pointer, val *bool)
- func (f *Field) SetBytes(structAddr unsafe.Pointer, val []byte)
- func (f *Field) SetBytesPtr(structAddr unsafe.Pointer, val *[]byte)
- func (f *Field) SetFloat32(structAddr unsafe.Pointer, val float32)
- func (f *Field) SetFloat32Ptr(structAddr unsafe.Pointer, val *float32)
- func (f *Field) SetFloat64(structAddr unsafe.Pointer, val float64)
- func (f *Field) SetFloat64Ptr(structAddr unsafe.Pointer, val *float64)
- func (f *Field) SetInt(structAddr unsafe.Pointer, val int)
- func (f *Field) SetInt16(structAddr unsafe.Pointer, val int16)
- func (f *Field) SetInt16Ptr(structAddr unsafe.Pointer, val *int16)
- func (f *Field) SetInt32(structAddr unsafe.Pointer, val int32)
- func (f *Field) SetInt32Ptr(structAddr unsafe.Pointer, val *int32)
- func (f *Field) SetInt64(structAddr unsafe.Pointer, val int64)
- func (f *Field) SetInt64Ptr(structAddr unsafe.Pointer, val *int64)
- func (f *Field) SetInt8(structAddr unsafe.Pointer, val int8)
- func (f *Field) SetInt8Ptr(structAddr unsafe.Pointer, val *int8)
- func (f *Field) SetIntPtr(structAddr unsafe.Pointer, val *int)
- func (f *Field) SetInterface(structAddr unsafe.Pointer, val interface{})
- func (f *Field) SetString(structAddr unsafe.Pointer, val string)
- func (f *Field) SetStringPtr(structAddr unsafe.Pointer, val *string)
- func (f *Field) SetTime(structAddr unsafe.Pointer, val time.Time)
- func (f *Field) SetTimePtr(structAddr unsafe.Pointer, val *time.Time)
- func (f *Field) SetUint(structAddr unsafe.Pointer, val uint)
- func (f *Field) SetUint16(structAddr unsafe.Pointer, val uint16)
- func (f *Field) SetUint16Ptr(structAddr unsafe.Pointer, val *uint16)
- func (f *Field) SetUint32(structAddr unsafe.Pointer, val uint32)
- func (f *Field) SetUint32Ptr(structAddr unsafe.Pointer, val *uint32)
- func (f *Field) SetUint64(structAddr unsafe.Pointer, val uint64)
- func (f *Field) SetUint64Ptr(structAddr unsafe.Pointer, val *uint64)
- func (f *Field) SetUint8(structAddr unsafe.Pointer, val uint8)
- func (f *Field) SetUint8Ptr(structAddr unsafe.Pointer, val *uint8)
- func (f *Field) SetUintPtr(structAddr unsafe.Pointer, val *uint)
- func (f *Field) SetValue(structAddr unsafe.Pointer, val interface{})
- func (f *Field) String(structAddr unsafe.Pointer) string
- func (f *Field) StringAddr(structAddr unsafe.Pointer) *string
- func (f *Field) StringPtr(structAddr unsafe.Pointer) *string
- func (f *Field) Time(structAddr unsafe.Pointer) time.Time
- func (f *Field) TimeAddr(structAddr unsafe.Pointer) *time.Time
- func (f *Field) TimePtr(structAddr unsafe.Pointer) *time.Time
- func (f *Field) Uint(structAddr unsafe.Pointer) uint
- func (f *Field) Uint16(structAddr unsafe.Pointer) uint16
- func (f *Field) Uint16Addr(structAddr unsafe.Pointer) *uint16
- func (f *Field) Uint16Ptr(structAddr unsafe.Pointer) *uint16
- func (f *Field) Uint32(structAddr unsafe.Pointer) uint32
- func (f *Field) Uint32Addr(structAddr unsafe.Pointer) *uint32
- func (f *Field) Uint32Ptr(structAddr unsafe.Pointer) *uint32
- func (f *Field) Uint64(structAddr unsafe.Pointer) uint64
- func (f *Field) Uint64Addr(structAddr unsafe.Pointer) *uint64
- func (f *Field) Uint64Ptr(structAddr unsafe.Pointer) *uint64
- func (f *Field) Uint8(structAddr unsafe.Pointer) uint8
- func (f *Field) Uint8Addr(structAddr unsafe.Pointer) *uint8
- func (f *Field) Uint8Ptr(structAddr unsafe.Pointer) *uint8
- func (f *Field) UintAddr(structAddr unsafe.Pointer) *uint
- func (f *Field) UintPtr(structAddr unsafe.Pointer) *uint
- func (f *Field) Value(structAddr unsafe.Pointer) interface{}
- type Getter
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Addr ¶
Addr returns src unsafe addr
Example ¶
package main import ( "fmt" "github.com/viant/xunsafe" "reflect" ) func main() { type Foo struct { ID int Name string } fooType := reflect.TypeOf(Foo{}) fooID := xunsafe.FieldByName(fooType, "ID") foo := &Foo{ID: 101, Name: "name 101"} fooAddr := xunsafe.Addr(foo) *(fooID.Addr(fooAddr).(*int)) = 201 fmt.Printf("foo.ID: %v\n", foo.ID) //prints 201 }
Output:
Types ¶
type Field ¶
type Field struct { Field *Field // contains filtered or unexported fields }
Field represent a field
func FieldByIndex ¶
FieldByIndex creates a field for supplied struct type and field index
func FieldByName ¶
FieldByName creates a field for supplied struct type and field name
func FieldWithGetters ¶
FieldWithGetters creates a field supplied custom address, value getter
func (*Field) AddrGetter ¶
AddrGetter creates a Getter function returning filed pointer or error
func (*Field) Float32Addr ¶
Float32Addr returns field *float32 addr
func (*Field) Float32Ptr ¶
Float32Ptr returns field *float32
func (*Field) Float64Addr ¶
Float64Addr returns field *float64 addr
func (*Field) Float64Ptr ¶
Float64Ptr returns field *float64
func (*Field) SetBoolPtr ¶
SetBoolPtr sets field *bool
func (*Field) SetBytesPtr ¶
SetBytesPtr sets field *[]byte
func (*Field) SetFloat32 ¶
SetFloat32 sets field float32
func (*Field) SetFloat32Ptr ¶
SetFloat32Ptr sets field *float32
func (*Field) SetFloat64 ¶
SetFloat64 sets field float64
func (*Field) SetFloat64Ptr ¶
SetFloat64Ptr sets field *float64
func (*Field) SetInt16Ptr ¶
SetInt16Ptr sets field *int
func (*Field) SetInt32Ptr ¶
SetInt32Ptr sets field *int
func (*Field) SetInt64Ptr ¶
SetInt64Ptr sets field *int
func (*Field) SetInt8Ptr ¶
SetInt8Ptr sets field *int
func (*Field) SetInterface ¶
SetInterface set field interface{}
func (*Field) SetStringPtr ¶
SetStringPtr sets field *string
func (*Field) SetTimePtr ¶
SetTimePtr sets field *time.Time
func (*Field) SetUint16Ptr ¶
SetUint16Ptr sets field *uint
func (*Field) SetUint32Ptr ¶
SetUint32Ptr sets field *uint
func (*Field) SetUint64Ptr ¶
SetUint64Ptr sets field *uint
func (*Field) SetUint8Ptr ¶
SetUint8Ptr sets field *uint
func (*Field) SetUintPtr ¶
SetUintPtr sets field *uint
func (*Field) StringAddr ¶
StringAddr returns field *string addr
func (*Field) Uint16Addr ¶
Uint16Addr returns field *uint16 addr
func (*Field) Uint32Addr ¶
Uint32Addr returns field *uint32 addr
func (*Field) Uint64Addr ¶
Uint64Addr returns field *uint64 addr