Documentation ¶
Index ¶
- Constants
- func ArrayMake(length int, elem any) any
- func CopyFieldValue(src any, dst any)
- func FuncMake(in, out []any, variadic bool, metaFunc MetaFunc) any
- func HasField(v any, fieldName string, fieldVal any) (ok bool)
- func HasFields(v any, fields map[string]any) bool
- func InterfaceOf(v reflect.Value) any
- func InterfacesOf(v []reflect.Value) []any
- func IsArray(v reflect.Value) bool
- func IsBool(v reflect.Value) bool
- func IsChan(v reflect.Value) bool
- func IsFloat(v reflect.Value) bool
- func IsFunc(v reflect.Value) bool
- func IsInt(v reflect.Value) bool
- func IsMap(v reflect.Value) bool
- func IsSlice(v reflect.Value) bool
- func IsString(v reflect.Value) bool
- func IsStruct(v reflect.Value) bool
- func IsUint(v reflect.Value) bool
- func MapMake(key, elem any, capacity int) any
- func SetField(v any, fieldName string, fieldVal any)
- func SetFields(v any, fields map[string]any)
- func SliceMake(elem any, length, capacity int) any
- func StructMake(fields []FieldDesc) any
- type FieldDesc
- type MetaFunc
- type TagMap
- type TypVal
- func (tv TypVal) ArraySet(index int, elem any)
- func (tv TypVal) ArraySetStructFields(fields map[string]any)
- func (tv TypVal) CanDirectAssign() bool
- func (tv TypVal) CanDirectCompare() bool
- func (tv TypVal) FieldLen() int
- func (tv TypVal) FuncCall(in []any) ([]any, bool)
- func (tv TypVal) FuncSet(fn any)
- func (tv TypVal) HasMethod(methodName string, in, out []any) bool
- func (tv TypVal) MapAssign(key, elem any)
- func (tv TypVal) MapAssign2(key, elem any)
- func (tv TypVal) MapAssignMake(key, elem any)
- func (tv TypVal) MapDelete(key any)
- func (tv TypVal) MapKeyOk(key any) bool
- func (tv TypVal) SliceAppend(elem any)
- func (tv TypVal) SliceAppendSlice(sl any)
- func (tv TypVal) SliceAppends(elem ...any)
- func (tv TypVal) SliceOrArrayStructHasFields(fields map[string]any) map[string]struct{}
- func (tv TypVal) SliceSet(index int, elem any)
- func (tv TypVal) SliceSetMake(index int, elem any)
- func (tv TypVal) SliceSetOoc(index int, elem any)
- func (tv TypVal) SliceSetOol(index int, elem any)
- func (tv TypVal) SliceSetStructFields(fields map[string]any)
- func (tv TypVal) SliceStruct2SliceMap(fields map[string]struct{}) []map[string]any
- func (tv TypVal) SliceStructFieldValues(fieldName string) map[any]struct{}
- func (tv TypVal) SliceStructFieldsValues(fields map[string]struct{}) map[string]map[any]struct{}
- func (tv TypVal) Struct2Map(fields map[string]struct{}) map[string]any
- func (tv TypVal) Struct2TagKeyMap(app, key string) map[string]any
- func (tv TypVal) StructFieldValue(fieldName string) any
- func (tv TypVal) StructFieldsIndex() map[string][]int
- func (tv TypVal) StructFieldsType() map[string]reflect.Type
- func (tv TypVal) StructFieldsValues(fields map[string][]int) map[string]map[any]struct{}
- func (tv TypVal) StructHasFields(fields map[string]any) map[string]struct{}
- func (tv TypVal) StructMakeSlice(length, capacity int) any
- func (tv TypVal) StructParseTag(app string) (tagMap TagMap)
- func (tv TypVal) StructSet(srcV any)
- func (tv TypVal) StructSetFields(fields map[string]any)
Constants ¶
const ( Invalid reflect.Kind = iota Bool Int I8 I16 I32 I64 Uint U8 U16 U32 U64 UPtr F32 F64 C64 C128 Arr Chan Func Any Map Ptr Slice String Struct UnsafePtr )
alias of reflect.Kind
Variables ¶
This section is empty.
Functions ¶
func CopyFieldValue ¶
CopyFieldValue copy field value in src to dst which fields with same name and same type regardless src type same with dst type no deep copy, only one level iface +case 1 src can be Struct, Struct Pointer, Struct Pointer to Pointer, Struct Pointer to..., ... dst must be Struct Pointer, Struct Pointer to Pointer, Struct Pointer to..., ...
func HasField ¶
HasField check type: 1. struct that do not allow embedded field 2. array elem is struct 3. slice elem is struct 4. map[string]any 5. latter: []map[string]any
func InterfaceOf ¶ added in v1.1.9
func InterfacesOf ¶ added in v1.1.9
func StructMake ¶ added in v1.2.0
Types ¶
type FieldDesc ¶ added in v1.2.0
func (FieldDesc) StructField ¶ added in v1.2.0
func (f FieldDesc) StructField() reflect.StructField
type TagMap ¶
TagMap in an app -> map[field]tag_val
func (TagMap) ParseGetVal ¶ added in v1.2.0
ParseGetVal +example `gorm:"column:user_name;type:varchar(128);comment:user's name, account's name"` +example `app:"unique:1;union_unique:0;field:name;"` `app:"unique:0;union_unique:1;field:name_part1;follow:-"` `app:"unique:0;union_unique:1;field:name_part1;follow:+"`
type TypVal ¶
type TypVal struct { // final Value and final Type Typ reflect.Type Val reflect.Value // contains filtered or unexported fields }
func IndirectOf ¶
func (TypVal) ArraySetStructFields ¶
ArraySetStructFields set array struct fields fieldName to fieldVal
func (TypVal) CanDirectAssign ¶
CanDirectAssign only use Type not use flag, a bit of incoming rule
func (TypVal) CanDirectCompare ¶ added in v1.2.1
func (TypVal) MapAssignMake ¶ added in v1.1.9
MapAssignMake if nil make map
func (TypVal) SliceAppend ¶ added in v1.2.1
func (TypVal) SliceAppendSlice ¶ added in v1.2.1
func (TypVal) SliceAppends ¶ added in v1.2.1
func (TypVal) SliceOrArrayStructHasFields ¶ added in v1.2.6
like TypVal.StructHasFields only check type not value
func (TypVal) SliceSetMake ¶ added in v1.1.9
SliceSetMake set slice index to elem -> slice[index] = elem allow slice is nil, if slice is nil make a slice allow index out of bound capacity, auto resize length and resize capacity
func (TypVal) SliceSetOoc ¶ added in v1.1.9
SliceSetOoc set slice index to elem -> slice[index] = elem that allow length and capacity out of bound
func (TypVal) SliceSetOol ¶ added in v1.1.9
SliceSetOol set slice index to elem -> slice[index] = elem that allow length out of bound, but capacity inbound
func (TypVal) SliceSetStructFields ¶
SliceSetStructFields set slice struct fields fieldName to fieldVal
func (TypVal) SliceStruct2SliceMap ¶ added in v1.2.3
func (TypVal) SliceStructFieldValues ¶ added in v1.2.2
func (TypVal) SliceStructFieldsValues ¶ added in v1.2.1
func (TypVal) Struct2Map ¶ added in v1.2.3
func (TypVal) Struct2TagKeyMap ¶ added in v1.2.7
Struct2TagKeyMap +example `app:"unique:1;union_unique:0;field:name;"` `app:"unique:0;union_unique:1;field:name_part1;follow:-"` `app:"unique:0;union_unique:1;field:name_part1;follow:+"`
func (TypVal) StructFieldValue ¶ added in v1.2.2
func (TypVal) StructFieldsIndex ¶ added in v1.2.1
func (TypVal) StructFieldsType ¶ added in v1.2.1
func (TypVal) StructFieldsValues ¶ added in v1.2.1
func (TypVal) StructHasFields ¶ added in v1.2.6
StructHasFields match all fields by FieldName and FieldType fields FieldValue must direct
func (TypVal) StructMakeSlice ¶ added in v1.2.5
func (TypVal) StructParseTag ¶ added in v1.2.0
StructParseTag +example `app1:"tag_val1" app2:"tag_val2" app3:"tag_val3"`