按功能拆分文件

This commit is contained in:
Yun
2025-09-21 16:30:45 +08:00
parent e57caf3080
commit 77a8322aad
7 changed files with 314 additions and 210 deletions
+6 -33
View File
@@ -2,7 +2,6 @@ package structx
import (
"reflect"
"sync"
)
// ChangeInfo 变更信息
@@ -14,41 +13,15 @@ type ChangeInfo struct {
// FieldInfo 字段信息
type FieldInfo struct {
Index []int
Name string
IsPtr bool
FieldType reflect.Type
IsSlice bool
IsArray bool
Index []int // 字段索引路径
Name string // 字段名
IsPtr bool // 是否为指针
FieldType reflect.Type // 字段类型
IsSlice bool // 是否为切片
IsArray bool // 是否为数组
}
// converterFunc 类型转换函数
type converterFunc func(reflect.Value, string) (interface{}, error)
var (
typeConverters = map[reflect.Kind]converterFunc{
reflect.Bool: convertBool,
reflect.Int: convertInt[int],
reflect.Int8: convertInt[int8],
reflect.Int16: convertInt[int16],
reflect.Int32: convertInt[int32],
reflect.Int64: convertInt[int64],
reflect.Uint: convertUint[uint],
reflect.Uint8: convertUint[uint8],
reflect.Uint16: convertUint[uint16],
reflect.Uint32: convertUint[uint32],
reflect.Uint64: convertUint[uint64],
reflect.Float32: convertFloat[float32],
reflect.Float64: convertFloat[float64],
reflect.String: convertString,
reflect.Slice: convertSlice,
reflect.Array: convertArray,
reflect.Map: convertMap,
}
typeInfoCache = make(map[reflect.Type]map[string]FieldInfo)
cacheMutex = &sync.RWMutex{}
basicStructTypes = map[string]bool{
"time.Time": true,
"github.com/shopspring/decimal.Decimal": true,