Skip to content

Commit 380ab17

Browse files
committed
Fix cleanup
1 parent 8926f29 commit 380ab17

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

internal/hscan/structmap.go

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ func newStructMap() *structMap {
2929

3030
func (s *structMap) get(t reflect.Type) *structFields {
3131
if v, ok := s.m.Load(t); ok {
32-
return m.(*structFields), ok
32+
return v.(*structFields)
3333
}
3434

35-
fMap := getStructFields(v, "redis")
35+
fMap := getStructFields(t, "redis")
3636
s.m.Store(t, fMap)
37-
return fmap, true
37+
return fMap
3838
}
3939

4040
func newStructFields() *structFields {
@@ -52,19 +52,16 @@ func (s *structFields) get(tag string) (*structField, bool) {
5252
return f, ok
5353
}
5454

55-
func getStructFields(ob reflect.Value, fieldTag string) *structFields {
55+
func getStructFields(t reflect.Type, fieldTag string) *structFields {
5656
var (
57-
num = ob.NumField()
57+
num = t.NumField()
5858
out = newStructFields()
5959
)
6060

6161
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)
6663

67-
tag := ob.Type().Field(i).Tag.Get(fieldTag)
64+
tag := t.Field(i).Tag.Get(fieldTag)
6865
if tag == "" || tag == "-" {
6966
continue
7067
}
@@ -75,7 +72,7 @@ func getStructFields(ob reflect.Value, fieldTag string) *structFields {
7572
}
7673

7774
// 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()]})
7976
}
8077

8178
return out

0 commit comments

Comments
 (0)