| 53 | ) |
| 54 | |
| 55 | func Struct(dst interface{}) (StructValue, error) { |
| 56 | v := reflect.ValueOf(dst) |
| 57 | |
| 58 | // The destination to scan into should be a struct pointer. |
| 59 | if v.Kind() != reflect.Ptr || v.IsNil() { |
| 60 | return StructValue{}, fmt.Errorf("redis.Scan(non-pointer %T)", dst) |
| 61 | } |
| 62 | |
| 63 | v = v.Elem() |
| 64 | if v.Kind() != reflect.Struct { |
| 65 | return StructValue{}, fmt.Errorf("redis.Scan(non-struct %T)", dst) |
| 66 | } |
| 67 | |
| 68 | return StructValue{ |
| 69 | spec: globalStructMap.get(v.Type()), |
| 70 | value: v, |
| 71 | }, nil |
| 72 | } |
| 73 | |
| 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. |