reflects

package
v0.0.0-...-c18a219 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 20, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	TypeError    = reflect.TypeOf((*error)(nil)).Elem()
	TypeContext  = reflect.TypeOf((*context.Context)(nil)).Elem()
	TypeString   = reflect.TypeOf("")
	TypeBool     = reflect.TypeOf(true)
	TypeBytes    = reflect.TypeOf([]byte{})
	TypeInt      = reflect.TypeOf(int(0))
	TypeInt8     = reflect.TypeOf(int8(0))
	TypeInt16    = reflect.TypeOf(int16(0))
	TypeInt32    = reflect.TypeOf(int32(0))
	TypeInt64    = reflect.TypeOf(int64(0))
	TypeUint     = reflect.TypeOf(uint(0))
	TypeUint8    = reflect.TypeOf(uint8(0))
	TypeUint16   = reflect.TypeOf(uint16(0))
	TypeUint32   = reflect.TypeOf(uint32(0))
	TypeUint64   = reflect.TypeOf(uint64(0))
	TypeFloat32  = reflect.TypeOf(float32(0))
	TypeFloat64  = reflect.TypeOf(float64(0))
	TypeTime     = reflect.TypeOf(time.Time{})
	TypeDuration = reflect.TypeOf(time.Duration(0))
)
View Source
var (
	ZeroError = reflect.Zero(TypeError)
)

Functions

func Connect

func Connect(dst, src interface{}) error

Connect fill all func fields of dst with methods of src.

func Error

func Error(err error) reflect.Value

func Indirect

func Indirect(v reflect.Value) reflect.Value

func Interface

func Interface(v reflect.Value) interface{}

Interface convert v to it's interface value, if v is nil value, return nil directly

func IsEmpty

func IsEmpty(v reflect.Value) bool

func Pointer

func Pointer(i interface{}) unsafe.Pointer

func Ptr

func Ptr(i interface{}) uintptr

func RegisterFieldAccessor

func RegisterFieldAccessor(t reflect.Type, accessor *FieldAccessor)

func SliceLen

func SliceLen(i interface{}) int

func SlicePointer

func SlicePointer(i interface{}) unsafe.Pointer

func SlicePtr

func SlicePtr(i interface{}) uintptr

func Value

func Value(i interface{}, t reflect.Type) reflect.Value

Types

type ArrayValue

type ArrayValue reflect.Value

func ArrayOf

func ArrayOf(v reflect.Value) ArrayValue

func (ArrayValue) Get

func (av ArrayValue) Get(i int) interface{}

func (ArrayValue) GetValue

func (av ArrayValue) GetValue(i int) reflect.Value

func (ArrayValue) Interface

func (av ArrayValue) Interface() interface{}

func (ArrayValue) Set

func (av ArrayValue) Set(i int, x interface{})

func (ArrayValue) SetValue

func (av ArrayValue) SetValue(i int, x reflect.Value)

type FieldAccessor

type FieldAccessor struct {
	Get        func(ptr uintptr, f *reflect.StructField) interface{}
	Set        func(ptr uintptr, f *reflect.StructField, v interface{})
	GetPointer func(ptr uintptr, f *reflect.StructField) interface{}
}

type FieldInfo

type FieldInfo struct {
	*reflect.StructField
	// contains filtered or unexported fields
}

func NewFieldInfo

func NewFieldInfo(f *reflect.StructField) *FieldInfo

func (*FieldInfo) Get

func (f *FieldInfo) Get(ptr uintptr) interface{}

func (*FieldInfo) GetPointer

func (f *FieldInfo) GetPointer(ptr uintptr) interface{}

func (*FieldInfo) Set

func (f *FieldInfo) Set(ptr uintptr, v interface{})

type MapValue

type MapValue reflect.Value

func MapOf

func MapOf(v reflect.Value) MapValue

func (MapValue) Delete

func (mv MapValue) Delete(key interface{})

func (MapValue) DeleteValue

func (mv MapValue) DeleteValue(key reflect.Value)

func (MapValue) Get

func (mv MapValue) Get(key interface{}) interface{}

func (MapValue) GetValue

func (mv MapValue) GetValue(key reflect.Value) reflect.Value

func (MapValue) Interface

func (mv MapValue) Interface() interface{}

func (MapValue) Set

func (mv MapValue) Set(key, value interface{})

func (MapValue) SetValue

func (mv MapValue) SetValue(key, value reflect.Value)

type SimpleValue

type SimpleValue reflect.Value

func SimpleOf

func SimpleOf(v reflect.Value) SimpleValue

func (SimpleValue) Interface

func (sv SimpleValue) Interface() interface{}

func (SimpleValue) Set

func (sv SimpleValue) Set(x interface{})

func (SimpleValue) SetValue

func (sv SimpleValue) SetValue(x reflect.Value)

type SliceInfo

type SliceInfo struct {
	// contains filtered or unexported fields
}

func NewSliceInfo

func NewSliceInfo(t reflect.Type) *SliceInfo

func (*SliceInfo) Get

func (s *SliceInfo) Get(ptr uintptr, i int) interface{}

func (*SliceInfo) GetBool

func (s *SliceInfo) GetBool(ptr uintptr, i int) bool

func (*SliceInfo) GetInt

func (s *SliceInfo) GetInt(ptr uintptr, i int) int

func (*SliceInfo) GetInt16

func (s *SliceInfo) GetInt16(ptr uintptr, i int) int16

func (*SliceInfo) GetInt32

func (s *SliceInfo) GetInt32(ptr uintptr, i int) int32

func (*SliceInfo) GetInt64

func (s *SliceInfo) GetInt64(ptr uintptr, i int) int64

func (*SliceInfo) GetInt8

func (s *SliceInfo) GetInt8(ptr uintptr, i int) int8

func (*SliceInfo) GetString

func (s *SliceInfo) GetString(ptr uintptr, i int) string

func (*SliceInfo) GetUint

func (s *SliceInfo) GetUint(ptr uintptr, i int) uint

func (*SliceInfo) GetUint16

func (s *SliceInfo) GetUint16(ptr uintptr, i int) uint16

func (*SliceInfo) GetUint32

func (s *SliceInfo) GetUint32(ptr uintptr, i int) uint32

func (*SliceInfo) GetUint64

func (s *SliceInfo) GetUint64(ptr uintptr, i int) uint64

func (*SliceInfo) GetUint8

func (s *SliceInfo) GetUint8(ptr uintptr, i int) uint8

func (*SliceInfo) Set

func (s *SliceInfo) Set(ptr uintptr, i int, v interface{})

func (*SliceInfo) SetBool

func (s *SliceInfo) SetBool(ptr uintptr, i int, v bool)

func (*SliceInfo) SetInt

func (s *SliceInfo) SetInt(ptr uintptr, i int, v int)

func (*SliceInfo) SetInt16

func (s *SliceInfo) SetInt16(ptr uintptr, i int, v int16)

func (*SliceInfo) SetInt32

func (s *SliceInfo) SetInt32(ptr uintptr, i int, v int32)

func (*SliceInfo) SetInt64

func (s *SliceInfo) SetInt64(ptr uintptr, i int, v int64)

func (*SliceInfo) SetInt8

func (s *SliceInfo) SetInt8(ptr uintptr, i int, v int8)

func (*SliceInfo) SetString

func (s *SliceInfo) SetString(ptr uintptr, i int, v string)

func (*SliceInfo) SetUint

func (s *SliceInfo) SetUint(ptr uintptr, i int, v uint)

func (*SliceInfo) SetUint16

func (s *SliceInfo) SetUint16(ptr uintptr, i int, v uint16)

func (*SliceInfo) SetUint32

func (s *SliceInfo) SetUint32(ptr uintptr, i int, v uint32)

func (*SliceInfo) SetUint64

func (s *SliceInfo) SetUint64(ptr uintptr, i int, v uint64)

func (*SliceInfo) SetUint8

func (s *SliceInfo) SetUint8(ptr uintptr, i int, v uint8)

type SliceValue

type SliceValue reflect.Value

func SliceOf

func SliceOf(v reflect.Value) SliceValue

func (SliceValue) Add

func (sv SliceValue) Add(x interface{})

func (SliceValue) AddValue

func (sv SliceValue) AddValue(x ...reflect.Value)

func (SliceValue) Get

func (sv SliceValue) Get(i int) interface{}

func (SliceValue) GetValue

func (sv SliceValue) GetValue(i int) reflect.Value

func (SliceValue) Interface

func (sv SliceValue) Interface() interface{}

func (SliceValue) Set

func (sv SliceValue) Set(i int, x interface{})

func (SliceValue) SetValue

func (sv SliceValue) SetValue(i int, x reflect.Value)

type StructTag

type StructTag reflect.StructTag

func (StructTag) All

func (tag StructTag) All() map[string]string

func (StructTag) Find

func (tag StructTag) Find(key string, alias ...string) string

type StructValue

type StructValue reflect.Value

func StructOf

func StructOf(v reflect.Value) StructValue

func (StructValue) Interface

func (sv StructValue) Interface() interface{}

func (StructValue) VisitFields

func (sv StructValue) VisitFields(fn func(fv reflect.Value, fi *reflect.StructField) error) error

func (StructValue) VisitMethods

func (sv StructValue) VisitMethods(fn func(mv reflect.Value, mi *reflect.Method) error) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL