Scan scans the results from a key-value Redis map result set to a destination struct. The Redis keys are matched to the struct's field with the `redis` tag.
(dst interface{}, keys []interface{}, vals []interface{})
| 74 | // Scan scans the results from a key-value Redis map result set to a destination struct. |
| 75 | // The Redis keys are matched to the struct's field with the `redis` tag. |
| 76 | func Scan(dst interface{}, keys []interface{}, vals []interface{}) error { |
| 77 | if len(keys) != len(vals) { |
| 78 | return errors.New("args should have the same number of keys and vals") |
| 79 | } |
| 80 | |
| 81 | strct, err := Struct(dst) |
| 82 | if err != nil { |
| 83 | return err |
| 84 | } |
| 85 | |
| 86 | // Iterate through the (key, value) sequence. |
| 87 | for i := 0; i < len(vals); i++ { |
| 88 | key, ok := keys[i].(string) |
| 89 | if !ok { |
| 90 | continue |
| 91 | } |
| 92 | |
| 93 | val, ok := vals[i].(string) |
| 94 | if !ok { |
| 95 | continue |
| 96 | } |
| 97 | |
| 98 | if err := strct.Scan(key, val); err != nil { |
| 99 | return err |
| 100 | } |
| 101 | } |
| 102 | |
| 103 | return nil |
| 104 | } |
| 105 | |
| 106 | func decodeBool(f reflect.Value, s string) error { |
| 107 | b, err := strconv.ParseBool(s) |
no test coverage detected