(data []string, slice interface{})
| 127 | } |
| 128 | |
| 129 | func ScanSlice(data []string, slice interface{}) error { |
| 130 | v := reflect.ValueOf(slice) |
| 131 | if !v.IsValid() { |
| 132 | return fmt.Errorf("redis: ScanSlice(nil)") |
| 133 | } |
| 134 | if v.Kind() != reflect.Ptr { |
| 135 | return fmt.Errorf("redis: ScanSlice(non-pointer %T)", slice) |
| 136 | } |
| 137 | v = v.Elem() |
| 138 | if v.Kind() != reflect.Slice { |
| 139 | return fmt.Errorf("redis: ScanSlice(non-slice %T)", slice) |
| 140 | } |
| 141 | |
| 142 | next := makeSliceNextElemFunc(v) |
| 143 | for i, s := range data { |
| 144 | elem := next() |
| 145 | if err := Scan([]byte(s), elem.Addr().Interface()); err != nil { |
| 146 | err = fmt.Errorf("redis: ScanSlice index=%d value=%q failed: %w", i, s, err) |
| 147 | return err |
| 148 | } |
| 149 | } |
| 150 | |
| 151 | return nil |
| 152 | } |
| 153 | |
| 154 | func makeSliceNextElemFunc(v reflect.Value) func() reflect.Value { |
| 155 | elemType := v.Type().Elem() |
no test coverage detected