structs

package
v1.0.9 Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const StrCallParamNumErrorMsg = "%s.%s需要%d个参数,实际传入%d个参数,参数类型不匹配"
View Source
const StrCallParamTypeErrorMsg = "%s.%s第%d个形参为%s类型,调用实参为%s类型,参数类型不匹配"

Variables

This section is empty.

Functions

func FieldGetBoolFunc

func FieldGetBoolFunc(inst interface{}, field IField) (interface{}, error)

func FieldGetBoolFuncV

func FieldGetBoolFuncV(instV reflect.Value, field IField) (interface{}, error)

func FieldGetBoolFuncVT

func FieldGetBoolFuncVT(instV reflect.Value, field IField) bool

func FieldGetChanFunc

func FieldGetChanFunc(inst interface{}, field IField) (interface{}, error)

func FieldGetChanFuncV

func FieldGetChanFuncV(instV reflect.Value, field IField) (interface{}, error)

func FieldGetComplex128Func

func FieldGetComplex128Func(inst interface{}, field IField) (interface{}, error)

func FieldGetComplex128FuncV

func FieldGetComplex128FuncV(instV reflect.Value, field IField) (interface{}, error)

func FieldGetComplex128FuncVT

func FieldGetComplex128FuncVT(instV reflect.Value, field IField) complex128

func FieldGetComplex64Func

func FieldGetComplex64Func(inst interface{}, field IField) (interface{}, error)

func FieldGetComplex64FuncV

func FieldGetComplex64FuncV(instV reflect.Value, field IField) (interface{}, error)

func FieldGetComplex64FuncVT

func FieldGetComplex64FuncVT(instV reflect.Value, field IField) complex64

func FieldGetFloat32Func

func FieldGetFloat32Func(inst interface{}, field IField) (interface{}, error)

func FieldGetFloat32FuncV

func FieldGetFloat32FuncV(instV reflect.Value, field IField) (interface{}, error)

func FieldGetFloat32FuncVT

func FieldGetFloat32FuncVT(instV reflect.Value, field IField) float32

func FieldGetFloat64Func

func FieldGetFloat64Func(inst interface{}, field IField) (interface{}, error)

func FieldGetFloat64FuncV

func FieldGetFloat64FuncV(instV reflect.Value, field IField) (interface{}, error)

func FieldGetFloat64FuncVT

func FieldGetFloat64FuncVT(instV reflect.Value, field IField) float64

func FieldGetInt16Func

func FieldGetInt16Func(inst interface{}, field IField) (interface{}, error)

func FieldGetInt16FuncV

func FieldGetInt16FuncV(instV reflect.Value, field IField) (interface{}, error)

func FieldGetInt16FuncVT

func FieldGetInt16FuncVT(instV reflect.Value, field IField) int16

func FieldGetInt32Func

func FieldGetInt32Func(inst interface{}, field IField) (interface{}, error)

func FieldGetInt32FuncV

func FieldGetInt32FuncV(instV reflect.Value, field IField) (interface{}, error)

func FieldGetInt32FuncVT

func FieldGetInt32FuncVT(instV reflect.Value, field IField) int32

func FieldGetInt64Func

func FieldGetInt64Func(inst interface{}, field IField) (interface{}, error)

func FieldGetInt64FuncV

func FieldGetInt64FuncV(instV reflect.Value, field IField) (interface{}, error)

func FieldGetInt64FuncVT

func FieldGetInt64FuncVT(instV reflect.Value, field IField) int64

func FieldGetInt8Func

func FieldGetInt8Func(inst interface{}, field IField) (interface{}, error)

func FieldGetInt8FuncV

func FieldGetInt8FuncV(instV reflect.Value, field IField) (interface{}, error)

func FieldGetIntFunc

func FieldGetIntFunc(inst interface{}, field IField) (interface{}, error)

func FieldGetIntFuncV

func FieldGetIntFuncV(instV reflect.Value, field IField) (interface{}, error)

func FieldGetIntFuncVT

func FieldGetIntFuncVT(instV reflect.Value, field IField) int

func FieldGetInterfaceFunc

func FieldGetInterfaceFunc(inst interface{}, field IField) (interface{}, error)

func FieldGetInterfaceFuncV

func FieldGetInterfaceFuncV(instV reflect.Value, field IField) (interface{}, error)

func FieldGetMapFunc

func FieldGetMapFunc(inst interface{}, field IField) (interface{}, error)

func FieldGetMapFuncV

func FieldGetMapFuncV(instV reflect.Value, field IField) (interface{}, error)

func FieldGetSliceFunc

func FieldGetSliceFunc(inst interface{}, field IField) (interface{}, error)

func FieldGetSliceFuncV

func FieldGetSliceFuncV(instV reflect.Value, field IField) (interface{}, error)

func FieldGetStringFunc

func FieldGetStringFunc(inst interface{}, field IField) (interface{}, error)

func FieldGetStringFuncV

func FieldGetStringFuncV(instV reflect.Value, field IField) (interface{}, error)

func FieldGetStringFuncVT

func FieldGetStringFuncVT(instV reflect.Value, field IField) string

func FieldGetUint16Func

func FieldGetUint16Func(inst interface{}, field IField) (interface{}, error)

func FieldGetUint16FuncV

func FieldGetUint16FuncV(instV reflect.Value, field IField) (interface{}, error)

func FieldGetUint16FuncVT

func FieldGetUint16FuncVT(instV reflect.Value, field IField) uint16

func FieldGetUint32Func

func FieldGetUint32Func(inst interface{}, field IField) (interface{}, error)

func FieldGetUint32FuncV

func FieldGetUint32FuncV(instV reflect.Value, field IField) (interface{}, error)

func FieldGetUint32FuncVT

func FieldGetUint32FuncVT(instV reflect.Value, field IField) uint32

func FieldGetUint64Func

func FieldGetUint64Func(inst interface{}, field IField) (interface{}, error)

func FieldGetUint64FuncV

func FieldGetUint64FuncV(instV reflect.Value, field IField) (interface{}, error)

func FieldGetUint64FuncVT

func FieldGetUint64FuncVT(instV reflect.Value, field IField) uint64

func FieldGetUint8Func

func FieldGetUint8Func(inst interface{}, field IField) (interface{}, error)

func FieldGetUint8FuncV

func FieldGetUint8FuncV(instV reflect.Value, field IField) (interface{}, error)

func FieldGetUint8FuncVT

func FieldGetUint8FuncVT(instV reflect.Value, field IField) uint8

func FieldGetUintFunc

func FieldGetUintFunc(inst interface{}, field IField) (interface{}, error)

func FieldGetUintFuncV

func FieldGetUintFuncV(instV reflect.Value, field IField) (interface{}, error)

func FieldSetBoolFunc

func FieldSetBoolFunc(inst interface{}, field IField, value interface{}) error

func FieldSetBoolFuncV

func FieldSetBoolFuncV(instV reflect.Value, field IField, value interface{}) error

func FieldSetChanFunc

func FieldSetChanFunc(inst interface{}, field IField, value interface{}) error

func FieldSetChanFuncV

func FieldSetChanFuncV(instV reflect.Value, field IField, value interface{}) error

func FieldSetComplex128Func

func FieldSetComplex128Func(inst interface{}, field IField, value interface{}) error

func FieldSetComplex128FuncV

func FieldSetComplex128FuncV(instV reflect.Value, field IField, value interface{}) error

func FieldSetComplex64Func

func FieldSetComplex64Func(inst interface{}, field IField, value interface{}) error

func FieldSetComplex64FuncV

func FieldSetComplex64FuncV(instV reflect.Value, field IField, value interface{}) error

func FieldSetFloat32Func

func FieldSetFloat32Func(inst interface{}, field IField, value interface{}) error

func FieldSetFloat32FuncV

func FieldSetFloat32FuncV(instV reflect.Value, field IField, value interface{}) error

func FieldSetFloat64Func

func FieldSetFloat64Func(inst interface{}, field IField, value interface{}) error

func FieldSetFloat64FuncV

func FieldSetFloat64FuncV(instV reflect.Value, field IField, value interface{}) error

func FieldSetInt16Func

func FieldSetInt16Func(inst interface{}, field IField, value interface{}) error

func FieldSetInt16FuncV

func FieldSetInt16FuncV(instV reflect.Value, field IField, value interface{}) error

func FieldSetInt32Func

func FieldSetInt32Func(inst interface{}, field IField, value interface{}) error

func FieldSetInt32FuncV

func FieldSetInt32FuncV(instV reflect.Value, field IField, value interface{}) error

func FieldSetInt64Func

func FieldSetInt64Func(inst interface{}, field IField, value interface{}) error

func FieldSetInt64FuncV

func FieldSetInt64FuncV(instV reflect.Value, field IField, value interface{}) error

func FieldSetInt8Func

func FieldSetInt8Func(inst interface{}, field IField, value interface{}) error

func FieldSetInt8FuncV

func FieldSetInt8FuncV(instV reflect.Value, field IField, value interface{}) error

func FieldSetIntFunc

func FieldSetIntFunc(inst interface{}, field IField, value interface{}) error

func FieldSetIntFuncV

func FieldSetIntFuncV(instV reflect.Value, field IField, value interface{}) error

func FieldSetMapFunc

func FieldSetMapFunc(inst interface{}, field IField, value interface{}) error

func FieldSetMapFuncV

func FieldSetMapFuncV(instV reflect.Value, field IField, value interface{}) error

func FieldSetPtrFunc

func FieldSetPtrFunc(inst interface{}, field IField, value interface{}) error

func FieldSetPtrFuncV

func FieldSetPtrFuncV(instV reflect.Value, field IField, value interface{}) error

func FieldSetSliceFunc

func FieldSetSliceFunc(inst interface{}, field IField, value interface{}) error

func FieldSetSliceFuncV

func FieldSetSliceFuncV(instV reflect.Value, field IField, value interface{}) error

func FieldSetStringFunc

func FieldSetStringFunc(inst interface{}, field IField, value interface{}) error

func FieldSetStringFuncV

func FieldSetStringFuncV(instV reflect.Value, field IField, value interface{}) error

func FieldSetStructFunc

func FieldSetStructFunc(inst interface{}, field IField, value interface{}) error

func FieldSetStructFuncV

func FieldSetStructFuncV(instV reflect.Value, field IField, value interface{}) error

func FieldSetUIntPtrFunc

func FieldSetUIntPtrFunc(inst interface{}, field IField, value interface{}) error

func FieldSetUIntPtrFuncV

func FieldSetUIntPtrFuncV(instV reflect.Value, field IField, value interface{}) error

func FieldSetUint16Func

func FieldSetUint16Func(inst interface{}, field IField, value interface{}) error

func FieldSetUint16FuncV

func FieldSetUint16FuncV(instV reflect.Value, field IField, value interface{}) error

func FieldSetUint32Func

func FieldSetUint32Func(inst interface{}, field IField, value interface{}) error

func FieldSetUint32FuncV

func FieldSetUint32FuncV(instV reflect.Value, field IField, value interface{}) error

func FieldSetUint64Func

func FieldSetUint64Func(inst interface{}, field IField, value interface{}) error

func FieldSetUint64FuncV

func FieldSetUint64FuncV(instV reflect.Value, field IField, value interface{}) error

func FieldSetUint8Func

func FieldSetUint8Func(inst interface{}, field IField, value interface{}) error

func FieldSetUint8FuncV

func FieldSetUint8FuncV(instV reflect.Value, field IField, value interface{}) error

func FieldSetUintFunc

func FieldSetUintFunc(inst interface{}, field IField, value interface{}) error

func FieldSetUintFuncV

func FieldSetUintFuncV(instV reflect.Value, field IField, value interface{}) error

func GetStructInstValue

func GetStructInstValue(inst interface{}) (reflect.Value, error)

func LeFillUpSize

func LeFillUpSize(b []byte, l int) []byte

当b位数不够时,进行高位补0。 注意这里为了不影响原有输入参数,是采用的值复制设计。

func MapField

func MapField(structPtr interface{}, priority []string, recursive bool) (map[string]IField, error)

func MemberGetInt8FuncVT

func MemberGetInt8FuncVT(instV reflect.Value, field IField) int8

func MemberGetUintFuncVT

func MemberGetUintFuncVT(instV reflect.Value, field IField) uint

func TagMapField

func TagMapField(structPtr interface{}, priority []string, recursive bool) (map[string]IField, error)

获取priority中的tagName映射字段

func TagMapName

func TagMapName(structPtr interface{}, priority []string, recursive bool) (map[string]string, error)

tag映射字段名

Types

type FieldGetFunc

type FieldGetFunc func(inst interface{}, field IField) (interface{}, error)

type FieldGetFuncV

type FieldGetFuncV func(instV reflect.Value, field IField) (interface{}, error)

type FieldSetFunc

type FieldSetFunc func(inst interface{}, field IField, value interface{}) error

struct字段值设置函数

type FieldSetFuncV

type FieldSetFuncV func(instV reflect.Value, field IField, value interface{}) error

type FieldTag

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

func NewFieldTag

func NewFieldTag(szTag ...string) *FieldTag

func (*FieldTag) Get

func (ft *FieldTag) Get(key string) TagValue

func (*FieldTag) HasKey

func (ft *FieldTag) HasKey(key string) bool

func (*FieldTag) Items

func (ft *FieldTag) Items() map[string]TagValue

func (*FieldTag) Parse

func (ft *FieldTag) Parse(szTag string) *FieldTag

func (*FieldTag) String

func (ft *FieldTag) String() string

type IField

type IField interface {
	Name() string
	Value() reflect.Value
	Tag() *FieldTag
	Type() reflect.Type
	Offset() uintptr
	Index() []int
	Get(inst ...interface{}) interface{}
	GetV(instValue ...reflect.Value) interface{}
	Set(val interface{}, inst ...interface{})
	SetV(val interface{}, instValue ...reflect.Value)
	Init(inst interface{}) IField
	Self() interface{}
}

func NewField

func NewField(name string, tag string, typ reflect.Type, val reflect.Value, index []int, offset uintptr, extends ...reflect.Type) (IField, error)

创建struct字段信息记录

func SliceStruct

func SliceStruct(structPtr interface{}) ([]IField, error)

type IMapField

type IMapField interface {
	KeyType() reflect.Type
	ValueType() reflect.Type
}

type IPtrField

type IPtrField interface {
	// 指针指向类型名称
	OriginType() reflect.Type
}

指针引用类型字段

type ISliceField

type ISliceField interface {
	ItemType() reflect.Type
}

type IStructField

type IStructField interface {
	StructType() reflect.Type
}

type MethodInfo

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

func NewMethodInfo

func NewMethodInfo(instance interface{}, instValue reflect.Value, name string, idx int) *MethodInfo

func (*MethodInfo) InParams

func (mi *MethodInfo) InParams() *MethodParams

func (*MethodInfo) Index

func (mi *MethodInfo) Index() int

func (*MethodInfo) Invoke

func (mi *MethodInfo) Invoke(params ...interface{}) (result []interface{}, err error)

调用方法

func (*MethodInfo) Name

func (mi *MethodInfo) Name() string

func (*MethodInfo) OutParams

func (mi *MethodInfo) OutParams() *MethodParams

func (*MethodInfo) OwnerName

func (mi *MethodInfo) OwnerName() string

func (*MethodInfo) SetInParams

func (mi *MethodInfo) SetInParams(params *MethodParams)

func (*MethodInfo) SetOutParams

func (mi *MethodInfo) SetOutParams(params *MethodParams)

func (*MethodInfo) String

func (mi *MethodInfo) String() string

type MethodParams

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

func NewMethodParams

func NewMethodParams(mi *MethodInfo, paramCount int) *MethodParams

func (*MethodParams) Add

func (mp *MethodParams) Add(item reflect.Type)

func (*MethodParams) CheckValues

func (mp *MethodParams) CheckValues(instance interface{}, values ...interface{}) (bool, error)

func (*MethodParams) Clear

func (mp *MethodParams) Clear()

func (*MethodParams) Count

func (mp *MethodParams) Count() int

func (*MethodParams) Items

func (mp *MethodParams) Items() []reflect.Type

func (*MethodParams) Set

func (mp *MethodParams) Set(index int, item reflect.Type)

func (*MethodParams) String

func (mp *MethodParams) String() string

type TField

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

func (*TField) Get

func (f *TField) Get(inst ...interface{}) interface{}

设置字段值,异常时panic

func (*TField) GetV

func (f *TField) GetV(instValue ...reflect.Value) interface{}

设置字段值,异常时panic

func (*TField) Index

func (f *TField) Index() []int

func (*TField) Init

func (f *TField) Init(inst interface{}) IField

func (*TField) Name

func (f *TField) Name() string

func (*TField) Offset

func (f *TField) Offset() uintptr

func (*TField) Self

func (f *TField) Self() interface{}

func (*TField) Set

func (f *TField) Set(val interface{}, inst ...interface{})

func (*TField) SetV

func (f *TField) SetV(val interface{}, instValue ...reflect.Value)

func (*TField) String

func (f *TField) String() string

func (*TField) Tag

func (f *TField) Tag() *FieldTag

func (*TField) Type

func (f *TField) Type() reflect.Type

func (*TField) Value

func (f *TField) Value() reflect.Value

type TMapField

type TMapField struct {
	TField
	// contains filtered or unexported fields
}

func (*TMapField) KeyType

func (mf *TMapField) KeyType() reflect.Type

func (*TMapField) String

func (mf *TMapField) String() string

func (*TMapField) ValueType

func (mf *TMapField) ValueType() reflect.Type

type TPtrField

type TPtrField struct {
	TField
	// contains filtered or unexported fields
}

func (*TPtrField) OriginType

func (pf *TPtrField) OriginType() reflect.Type

func (*TPtrField) String

func (pf *TPtrField) String() string

type TSliceField

type TSliceField struct {
	TField
	// contains filtered or unexported fields
}

func (*TSliceField) ItemType

func (sf *TSliceField) ItemType() reflect.Type

func (*TSliceField) String

func (sf *TSliceField) String() string

type TStruct

type TStruct struct {
	ExtraCols []string
	// contains filtered or unexported fields
}

func New

func New(v interface{}, tagName ...string) (*TStruct, error)

func (*TStruct) AppendResult

func (s *TStruct) AppendResult(arg map[string]interface{})

func (*TStruct) Call

func (s *TStruct) Call(method string, params ...interface{}) (result []interface{}, err error)

func (*TStruct) Field

func (s *TStruct) Field(fieldName string) IField

func (*TStruct) FieldMap

func (s *TStruct) FieldMap() map[string]IField

func (*TStruct) Fields

func (s *TStruct) Fields() []IField

func (*TStruct) GetFieldVal

func (s *TStruct) GetFieldVal(fieldName string) interface{}

func (*TStruct) GetResult

func (s *TStruct) GetResult() []map[string]interface{}

func (*TStruct) HasField

func (s *TStruct) HasField(fieldName string) bool

func (*TStruct) HasMethod

func (s *TStruct) HasMethod(method string) bool

func (*TStruct) Instance

func (s *TStruct) Instance() interface{}

func (*TStruct) Method

func (s *TStruct) Method(method string) *MethodInfo

func (*TStruct) MethodMap

func (s *TStruct) MethodMap() map[string]*MethodInfo

func (*TStruct) Methods

func (s *TStruct) Methods() []*MethodInfo

func (*TStruct) Name

func (s *TStruct) Name() string

func (*TStruct) SetExtraCols

func (s *TStruct) SetExtraCols(args []string) *TStruct

func (*TStruct) SetFieldVal

func (s *TStruct) SetFieldVal(fieldName string, val interface{})

func (*TStruct) SetResult

func (s *TStruct) SetResult(arg []map[string]interface{})

func (*TStruct) StructContent2Map

func (s *TStruct) StructContent2Map(data interface{}) []map[string]interface{}

func (*TStruct) TagName

func (s *TStruct) TagName() string

type TStructField

type TStructField struct {
	TField
	// contains filtered or unexported fields
}

func (*TStructField) String

func (sf *TStructField) String() string

func (*TStructField) StructType

func (sf *TStructField) StructType() reflect.Type

type TagValue

type TagValue string

func (TagValue) IsEmpty

func (tv TagValue) IsEmpty() bool

func (TagValue) Map

func (tv TagValue) Map() map[string]string

func (TagValue) Raw

func (tv TagValue) Raw() string

func (TagValue) String

func (tv TagValue) String() string

func (TagValue) Value

func (tv TagValue) Value() string

func (TagValue) Values

func (tv TagValue) Values() []string

Jump to

Keyboard shortcuts

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