getSlice checks s is a slice, returning the slice as a reflect.Value.
(s interface{})
| 165 | |
| 166 | // getSlice checks s is a slice, returning the slice as a reflect.Value. |
| 167 | func getSlice(s interface{}) (slice reflect.Value) { |
| 168 | slice = reflect.ValueOf(s) |
| 169 | if slice.Kind() != reflect.Slice { |
| 170 | panic(fmt.Errorf("s must be a slice, got: %T", s)) |
| 171 | } |
| 172 | return slice |
| 173 | } |
| 174 | |
| 175 | // toSlice returns the reflect.Value of v, turning it into a single element |
| 176 | // slice (of type sliceTy) if it isn't a slice already. |