|
34 | 34 | reflect.Interface: decodeUnsupported,
|
35 | 35 | reflect.Map: decodeUnsupported,
|
36 | 36 | reflect.Ptr: decodeUnsupported,
|
37 |
| - reflect.Slice: decodeStringSlice, |
| 37 | + reflect.Slice: decodeSlice, |
38 | 38 | reflect.String: decodeString,
|
39 | 39 | reflect.Struct: decodeUnsupported,
|
40 | 40 | reflect.UnsafePointer: decodeUnsupported,
|
@@ -69,12 +69,7 @@ func Scan(vals []interface{}, dest interface{}) error {
|
69 | 69 | // iterating through the fields of a struct type every time values are
|
70 | 70 | // scanned into it.
|
71 | 71 | typ := v.Type()
|
72 |
| - fMap, ok := structSpecs.get(typ) |
73 |
| - |
74 |
| - if !ok { |
75 |
| - fMap = makeStructSpecs(v, "redis") |
76 |
| - structSpecs.set(typ, fMap) |
77 |
| - } |
| 72 | + fMap := structSpecs.get(typ) |
78 | 73 |
|
79 | 74 | // Iterate through the (key, value) sequence.
|
80 | 75 | for i := 0; i < len(vals); i += 2 {
|
@@ -143,14 +138,14 @@ func decodeString(f reflect.Value, s string) error {
|
143 | 138 | return nil
|
144 | 139 | }
|
145 | 140 |
|
146 |
| -func decodeStringSlice(f reflect.Value, s string) error { |
| 141 | +func decodeSlice(f reflect.Value, s string) error { |
147 | 142 | // []byte slice ([]uint8).
|
148 | 143 | if f.Type().Elem().Kind() == reflect.Uint8 {
|
149 | 144 | f.SetBytes([]byte(s))
|
150 | 145 | }
|
151 | 146 | return nil
|
152 | 147 | }
|
153 | 148 |
|
154 |
| -func decodeUnsupported(f reflect.Value, s string) error { |
155 |
| - return fmt.Errorf("redis.Scan(unsupported type %v)", f) |
| 149 | +func decodeUnsupported(v reflect.Value, s string) error { |
| 150 | + return fmt.Errorf("redis.Scan(unsupported %s)", v.Type()) |
156 | 151 | }
|
0 commit comments