动态结构体,字段可导出

This commit is contained in:
白茶清欢 2024-08-23 18:30:24 +08:00
parent 59ba4ebfa5
commit c38d16dc28

View File

@ -152,6 +152,7 @@ func (ds *DynamicStruct) AddStructField(field reflect.StructField) {
if field.Tag == "" { if field.Tag == "" {
field.Tag = reflect.StructTag(fmt.Sprintf(`json:"%v"`, field.Name)) field.Tag = reflect.StructTag(fmt.Sprintf(`json:"%v"`, field.Name))
} }
field.Name = String(field.Name).SnakeCaseToCamel() // 转成大驼峰, 保证对外可访问
ds.structFieldList = append(ds.structFieldList, field) ds.structFieldList = append(ds.structFieldList, field)
} }