mirror of
https://github.com/duke-git/lancet.git
synced 2026-02-04 12:52:28 +08:00
Merge branch 'rc' into v2
This commit is contained in:
@@ -8,6 +8,9 @@ import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"golang.org/x/exp/constraints"
|
||||
|
||||
"golang.org/x/exp/constraints"
|
||||
|
||||
@@ -378,8 +381,7 @@ func getFieldNameByJsonTag(structObj any, jsonTag string) string {
|
||||
for i := 0; i < s.NumField(); i++ {
|
||||
field := s.Field(i)
|
||||
tag := field.Tag
|
||||
name := tag.Get("json")
|
||||
|
||||
name, _, _ := strings.Cut(tag.Get("json"), ",")
|
||||
if name == jsonTag {
|
||||
return field.Name
|
||||
}
|
||||
|
||||
@@ -485,7 +485,7 @@ func TestMapToStruct(t *testing.T) {
|
||||
Name string `json:"name"`
|
||||
Age int `json:"age"`
|
||||
Phone string `json:"phone"`
|
||||
Addr *Address `json:"address"`
|
||||
Addr *Address `json:"address,omitempty"`
|
||||
}
|
||||
|
||||
Address struct {
|
||||
|
||||
Reference in New Issue
Block a user