diff --git a/util/reflect/struct.go b/util/reflect/struct.go index 8342d21b..cfa136ff 100644 --- a/util/reflect/struct.go +++ b/util/reflect/struct.go @@ -46,9 +46,6 @@ func StructFieldByTag(src interface{}, tkey string, tval string) (interface{}, e if ts, ok := fld.Tag.Lookup(tkey); ok { for _, p := range strings.Split(ts, ",") { if p == tval { - if val.Kind() != reflect.Ptr && val.CanAddr() { - val = val.Addr() - } return val.Interface(), nil } } @@ -493,13 +490,14 @@ func btSplitter(str string) []string { } // queryToMap turns something like a[b][c]=4 into -// map[string]interface{}{ -// "a": map[string]interface{}{ -// "b": map[string]interface{}{ -// "c": 4, -// }, -// }, -// } +// +// map[string]interface{}{ +// "a": map[string]interface{}{ +// "b": map[string]interface{}{ +// "c": 4, +// }, +// }, +// } func queryToMap(param string) (map[string]interface{}, error) { rawKey, rawValue, err := splitKeyAndValue(param) if err != nil { diff --git a/util/reflect/struct_test.go b/util/reflect/struct_test.go index 00da531d..89be6de3 100644 --- a/util/reflect/struct_test.go +++ b/util/reflect/struct_test.go @@ -190,9 +190,9 @@ func TestStructFieldByTag(t *testing.T) { t.Fatal(err) } - if v, ok := iface.(*[]string); !ok { + if v, ok := iface.([]string); !ok { t.Fatalf("not *[]string %v", iface) - } else if len(*v) != 2 { + } else if len(v) != 2 { t.Fatalf("invalid number %v", iface) } }