mirror of
https://gitee.com/johng/gf
synced 2026-06-06 16:21:40 +08:00
add json tag support for struct converting of gconv
This commit is contained in:
@ -143,7 +143,11 @@ func getTagMapOfStruct(objPointer interface{}) map[string]string {
|
||||
}
|
||||
// 将struct中定义的属性转换名称构建成tagmap
|
||||
for _, field := range fields {
|
||||
if tag := field.Tag("gconv"); tag != "" {
|
||||
tag := field.Tag("gconv")
|
||||
if tag == "" {
|
||||
tag = field.Tag("json")
|
||||
}
|
||||
if tag != "" {
|
||||
for _, v := range strings.Split(tag, ",") {
|
||||
tagmap[strings.TrimSpace(v)] = field.Name()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user