reflect

package
v0.2.15 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2024 License: GPL-3.0 Imports: 12 Imported by: 13

Documentation

Index

Constants

This section is empty.

Variables

Functions

func Construct

func Construct[T any]() T

func DefaultStringSearch

func DefaultStringSearch(fieldName string) []string

func Endian

func Endian() binary.ByteOrder

func GetBool

func GetBool(raw any) bool

func GetField

func GetField(source any, field string) (any, error)

func GetFloat32

func GetFloat32(input any) float32

func GetFloat64

func GetFloat64(input any) float64

func GetFloatBase

func GetFloatBase(raw any, bitSize int) float64

func GetInt

func GetInt(input any) int

func GetInt16

func GetInt16(input any) int16

func GetInt32

func GetInt32(input any) int32

func GetInt64

func GetInt64(input any) int64

func GetInt8

func GetInt8(input any) int8

func GetIntBase

func GetIntBase(raw any, bitSize int) int64

func GetProtoTimestampMs

func GetProtoTimestampMs(raw any) *timestamppb.Timestamp

func GetString

func GetString(raw any) string

func GetTimestampMs

func GetTimestampMs(raw any) *time.Time

func GetUint

func GetUint(input any) uint

func GetUint16

func GetUint16(input any) uint16

func GetUint32

func GetUint32(input any) uint32

func GetUint64

func GetUint64(input any) uint64

func GetUint8

func GetUint8(input any) uint8

func GetUintBase

func GetUintBase(raw any, bitSize int) uint64

func GetValue

func GetValue(input any) (any, bool)

returns indirected value (or the same value if it is not a pointer), value is not default value (nil)

func IsNil

func IsNil(input any) bool

func IsPointer

func IsPointer(input any) bool

func TypeName added in v0.0.29

func TypeName(v any) string

func WithMapperFieldSearch

func WithMapperFieldSearch(fieldSearch func(string) []string) func(*Mapper) *Mapper

Types

type Mapper

type Mapper struct {
	Handler     map[reflect.Kind]func(interface{}, reflect.Type) reflect.Value
	FieldSearch func(string) []string
}

implementation

func NewMapper

func NewMapper(configurations ...func(*Mapper) *Mapper) *Mapper

constructor

func (*Mapper) GetFieldValue

func (mapper *Mapper) GetFieldValue(inputMap map[string]interface{}, fieldName string) (interface{}, bool)

func (*Mapper) PointerHandler

func (mapper *Mapper) PointerHandler(input interface{}, pointerType reflect.Type) reflect.Value

func (*Mapper) Set

func (mapper *Mapper) Set(target any, source any) any

func (*Mapper) SliceHandler

func (mapper *Mapper) SliceHandler(input interface{}, sliceType reflect.Type) reflect.Value

func (*Mapper) StructHandler

func (mapper *Mapper) StructHandler(input interface{}, structType reflect.Type) reflect.Value

Jump to

Keyboard shortcuts

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