|
@@ -353,3 +353,29 @@ func ToFloat64(data any) (float64, error) {
|
|
return 0, errors.New("不支持的类型: " + dataVal.Type().Elem().String())
|
|
return 0, errors.New("不支持的类型: " + dataVal.Type().Elem().String())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+func Zero(v *reflect.Value) {
|
|
|
|
+ if v.Kind() == reflect.Ptr {
|
|
|
|
+ elemValue := PointerValueElem(*v)
|
|
|
|
+ zero(&elemValue)
|
|
|
|
+ v.Set(elemValue.Addr())
|
|
|
|
+ } else if v.Kind() == reflect.Slice || v.Kind() == reflect.Array {
|
|
|
|
+ v.Set(reflect.MakeSlice(v.Type(), 0, 0))
|
|
|
|
+ } else if v.Kind() == reflect.Map {
|
|
|
|
+ v.Set(reflect.MakeMap(v.Type()))
|
|
|
|
+ } else {
|
|
|
|
+ v.Set(reflect.New(v.Type()).Elem())
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+func zero(v *reflect.Value) {
|
|
|
|
+ if v.Kind() == reflect.Slice || v.Kind() == reflect.Array {
|
|
|
|
+ v.Set(reflect.MakeSlice(v.Type(), 0, 0))
|
|
|
|
+ } else if v.Kind() == reflect.Map {
|
|
|
|
+ v.Set(reflect.MakeMap(v.Type()))
|
|
|
|
+ } else if v.Kind() == reflect.Chan {
|
|
|
|
+ v.Set(reflect.MakeChan(v.Type(), 0))
|
|
|
|
+ } else {
|
|
|
|
+ v.Set(reflect.New(v.Type()).Elem())
|
|
|
|
+ }
|
|
|
|
+}
|