Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6ba9140

Browse files
committed
修复资源发布时间显示不出来的bug
1 parent 78de144 commit 6ba9140

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

websites/code/studygolang/src/util/convert.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"net/url"
1212
"reflect"
1313
"strconv"
14+
"strings"
1415
)
1516

1617
// 将url.Values(表单数据)转换为Model(struct)
@@ -92,6 +93,9 @@ func Struct2Map(dest map[string]interface{}, src interface{}) error {
9293
}
9394
tag := fieldType.Tag.Get("json")
9495
fieldValue := srcValue.Field(i)
96+
97+
// json 有 key,omitempty 的情况
98+
tag = strings.Split(tag, ",")[0]
9599
dest[tag] = fieldValue.Interface()
96100
}
97101
return nil

0 commit comments

Comments
 (0)