Documentation ¶
Index ¶
- Constants
- func ArrayMake(length int, elem any) any
- func CanDirectCompare(typ reflect.Type) bool
- func CopyFieldValue(src any, dst any)
- func FuncMake(in, out []any, variadic bool, metaFunc MetaFunc) any
- func GetTags(v any, app, key string) []string
- func HasField(v any, fieldName string, fieldVal any) (ok bool)
- func HasFields(v any, fields map[string]any) bool
- func Impl(v any, iFace any) bool
- func IndirectImpl(v any, iFace any) (inst any, inst2 any)
- func IndirectRVal(v reflect.Value) reflect.Value
- 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 NewOf(typ reflect.Type) any
- func NewOf2(typ reflect.Type) any
- func Set(src, dst 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
- func StructType(v any) (typ reflect.Type, ok bool)
- type FieldDesc
- type FieldTagKV
- type MetaFunc
- type TagKV
- type TagMap
- type TagVV
- type TypVal
- func (tv TypVal) ArrayCanSet() bool
- 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) FuncCanSet() 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) MapDeleteElemIsZeroKeys()
- func (tv TypVal) MapKeyOk(key any) bool
- func (tv TypVal) SliceAppend(elem any)
- func (tv TypVal) SliceAppendSlice(slAdd any)
- func (tv TypVal) SliceAppends(elem ...any)
- func (tv TypVal) SliceOrArrayStructGetTagVal(app, key string) []string
- 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) Struct2MapAll() map[string]any
- func (tv TypVal) Struct2TagKeyMap(app, key string) map[string]any
- func (tv TypVal) StructCanSet() bool
- func (tv TypVal) StructFieldValue(fieldName string) any
- func (tv TypVal) StructFieldValueAll() map[string]reflect.Value
- func (tv TypVal) StructFieldsIndex() map[string][]int
- func (tv TypVal) StructFieldsType() map[string]reflect.Type
- func (tv TypVal) StructFieldsValues(fieldIndex 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) StructParseTag2(app0, key0, app1, key1 string) (vv0, vv1 TagVV)
- func (tv TypVal) StructParseTagKV(app string) (fieldTagKv FieldTagKV)
- func (tv TypVal) StructParseTagKV2(app string) (fieldTagKv FieldTagKV)
- 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
const ( EFace = Any IFace = Any )
Variables ¶
This section is empty.
Functions ¶
func CanDirectCompare ¶ added in v1.2.8
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 GetTags ¶ added in v1.2.13
GetTags +example:
type T1 struct { Name string `gorm:"column:name"` Desc string `gorm:"column:desc"` }
+param: v=T1{}, app="gorm", key="column" +result: {"name", "desc"}
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 Impl ¶ added in v1.2.11
Impl iFace must an iface or called not an empty interface
type _typeIFace interface { Method0(in...)out... Method1(in...)out... ... }
+param iFace var iFace = (*_typeIFace)(nil)
func IndirectImpl ¶ added in v1.2.14
IndirectImpl +param iFace same with Impl +param v specialized for T, *T, **T, *...*T -> T Arr, *Arr, *...*Arr -> Arr.Elem Slice, *Slice, *...*Slice -> Slice.Elem
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 TagKV ¶ added in v1.2.14
TagKV as parseTagKV description +example: `app:"k1:v1;k2:v2;k3:v3;key;val"` +result: k1 -> v1 k2 -> v2 k3 -> v3 key -> key val -> val
type TagMap ¶
TagMap in an app, fieldName -> fieldTag +example: Field0 string `app:"k1:v1;k2:v2;k3:v3;key;val"` +result: Field0 -> k1:v1;k2:v2;k3:v3;key;val
func (TagMap) GetValList ¶ added in v1.2.11
GetValList +example: Field0 string `app:"k1:v1;k2:v2;k3:v3;key;val"` Field1 string `app:"k1:v4;key-val"` +param: key = k1 +result: []string{v1, v4}
func (TagMap) ParseGetVal ¶ added in v1.2.0
ParseGetVal get val in an app's, field's, key's val +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) ArrayCanSet ¶ added in v1.2.15
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) FuncCall ¶ added in v1.2.0
FuncCall use param (in []any), to call func, result is ([]any, called)
func (TypVal) FuncCanSet ¶ added in v1.2.15
func (TypVal) HasMethod ¶ added in v1.2.7
HasMethod check if Typ has method by methodName and in: methodParamInType, out: methodResultOut
func (TypVal) MapAssignMake ¶ added in v1.1.9
MapAssignMake if nil make map
func (TypVal) MapDeleteElemIsZeroKeys ¶ added in v1.2.8
func (tv TypVal) MapDeleteElemIsZeroKeys()
Only support any-int, any-uint, any-string
func (TypVal) SliceAppend ¶ added in v1.2.1
SliceAppend stand for: sl = append(sl, elem)
func (TypVal) SliceAppendSlice ¶ added in v1.2.1
SliceAppendSlice stand for: sl = append(sl, slAdd...)
func (TypVal) SliceAppends ¶ added in v1.2.1
SliceAppends stand for: sl = append(sl, elem...)
func (TypVal) SliceOrArrayStructGetTagVal ¶ added in v1.2.11
SliceOrArrayStructGetTagVal get slice-struct or array-struct fields app key tag value
func (TypVal) SliceOrArrayStructHasFields ¶ added in v1.2.6
SliceOrArrayStructHasFields like 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
SliceStruct2SliceMap Struct to map[fieldName]fieldValue
func (TypVal) SliceStructFieldValues ¶ added in v1.2.2
SliceStructFieldValues []Struct get field(fieldName) values
func (TypVal) SliceStructFieldsValues ¶ added in v1.2.1
SliceStructFieldsValues []Struct get fields(fieldNames) values
func (TypVal) Struct2Map ¶ added in v1.2.3
func (TypVal) Struct2MapAll ¶ added in v1.2.29
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) StructCanSet ¶ added in v1.2.15
func (TypVal) StructFieldValue ¶ added in v1.2.2
func (TypVal) StructFieldValueAll ¶ added in v1.2.29
func (TypVal) StructFieldsIndex ¶ added in v1.2.1
StructFieldsIndex +result: fieldName -> fieldIndex
func (TypVal) StructFieldsType ¶ added in v1.2.1
StructFieldsType +result: fieldName -> fieldType
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
StructMakeSlice Type Struct -> return []Struct
func (TypVal) StructParseTag ¶ added in v1.2.0
StructParseTag +example `app1:"tag_val1" app2:"tag_val2" app3:"tag_val3"`
func (TypVal) StructParseTag2 ¶ added in v1.2.14
func (TypVal) StructParseTagKV ¶ added in v1.2.15
func (tv TypVal) StructParseTagKV(app string) (fieldTagKv FieldTagKV)
StructParseTagKV +param: an app +result: FieldTagKV
func (TypVal) StructParseTagKV2 ¶ added in v1.2.29
func (tv TypVal) StructParseTagKV2(app string) (fieldTagKv FieldTagKV)
StructParseTagKV2 +param: an app +result: FieldTagKV
func (TypVal) StructSetFields ¶
StructSetFields +param: fieldName -> fieldValue