|
@@ -7,8 +7,8 @@ import (
|
|
)
|
|
)
|
|
|
|
|
|
// GroupValueKind 将反射的Kind值进行聚集
|
|
// GroupValueKind 将反射的Kind值进行聚集
|
|
-func GroupValueKind(val reflect.Value) reflect.Kind {
|
|
|
|
- kind := val.Kind()
|
|
|
|
|
|
+func GroupValueKind(v reflect.Value) reflect.Kind {
|
|
|
|
+ kind := v.Kind()
|
|
|
|
|
|
switch {
|
|
switch {
|
|
case kind >= reflect.Int && kind <= reflect.Int64:
|
|
case kind >= reflect.Int && kind <= reflect.Int64:
|
|
@@ -22,6 +22,34 @@ func GroupValueKind(val reflect.Value) reflect.Kind {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+func IsInteger(v reflect.Value) bool {
|
|
|
|
+ return v.Kind() >= reflect.Int && v.Kind() <= reflect.Int64
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+func IsUnsignedInteger(v reflect.Value) bool {
|
|
|
|
+ return v.Kind() >= reflect.Uint && v.Kind() <= reflect.Uint64
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+func IsFloat(v reflect.Value) bool {
|
|
|
|
+ return v.Kind() >= reflect.Float32 && v.Kind() <= reflect.Float64
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+func IsValueStructPointer(v reflect.Value) bool {
|
|
|
|
+ return v.Kind() == reflect.Pointer && v.Kind() == reflect.Struct
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+func IsValueStructOrStructPointer(v reflect.Value) bool {
|
|
|
|
+ return v.Kind() == reflect.Struct || IsValueStructPointer(v)
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+func IsValueTime(v reflect.Value) bool {
|
|
|
|
+ return v.Kind() == reflect.Struct && v.Type().String() == "time.Time"
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+func IsValueTimePointer(v reflect.Value) bool {
|
|
|
|
+ return v.Kind() == reflect.Pointer && IsValueTime(v.Elem())
|
|
|
|
+}
|
|
|
|
+
|
|
// AssignStringValue 将any类型的值进行转化,赋值给string的reflect.Value
|
|
// AssignStringValue 将any类型的值进行转化,赋值给string的reflect.Value
|
|
func AssignStringValue(data any, val reflect.Value) error {
|
|
func AssignStringValue(data any, val reflect.Value) error {
|
|
if data == nil {
|
|
if data == nil {
|