@@ -29,12 +29,12 @@ func newStructMap() *structMap {
29
29
30
30
func (s * structMap ) get (t reflect.Type ) * structFields {
31
31
if v , ok := s .m .Load (t ); ok {
32
- return m .(* structFields ), ok
32
+ return v .(* structFields )
33
33
}
34
34
35
- fMap := getStructFields (v , "redis" )
35
+ fMap := getStructFields (t , "redis" )
36
36
s .m .Store (t , fMap )
37
- return fmap , true
37
+ return fMap
38
38
}
39
39
40
40
func newStructFields () * structFields {
@@ -52,19 +52,16 @@ func (s *structFields) get(tag string) (*structField, bool) {
52
52
return f , ok
53
53
}
54
54
55
- func getStructFields (ob reflect.Value , fieldTag string ) * structFields {
55
+ func getStructFields (t reflect.Type , fieldTag string ) * structFields {
56
56
var (
57
- num = ob .NumField ()
57
+ num = t .NumField ()
58
58
out = newStructFields ()
59
59
)
60
60
61
61
for i := 0 ; i < num ; i ++ {
62
- f := ob .Field (i )
63
- if ! f .IsValid () || ! f .CanSet () {
64
- continue
65
- }
62
+ f := t .Field (i )
66
63
67
- tag := ob . Type () .Field (i ).Tag .Get (fieldTag )
64
+ tag := t .Field (i ).Tag .Get (fieldTag )
68
65
if tag == "" || tag == "-" {
69
66
continue
70
67
}
@@ -75,7 +72,7 @@ func getStructFields(ob reflect.Value, fieldTag string) *structFields {
75
72
}
76
73
77
74
// Use the built-in decoder.
78
- out .set (tag , & structField {index : i , fn : decoders [f .Kind ()]})
75
+ out .set (tag , & structField {index : i , fn : decoders [f .Type . Kind ()]})
79
76
}
80
77
81
78
return out
0 commit comments