getSlicePtr checks s is a pointer to a slice, returning both the pointer and slice as a reflect.Value.
(s interface{})
| 152 | // getSlicePtr checks s is a pointer to a slice, returning both the pointer |
| 153 | // and slice as a reflect.Value. |
| 154 | func getSlicePtr(s interface{}) (ptr, slice reflect.Value) { |
| 155 | ptr = reflect.ValueOf(s) |
| 156 | if ptr.Kind() != reflect.Ptr { |
| 157 | panic(fmt.Errorf("s must be a pointer to a slice, got: %T", s)) |
| 158 | } |
| 159 | slice = ptr.Elem() |
| 160 | if slice.Kind() != reflect.Slice { |
| 161 | panic(fmt.Errorf("s must be a pointer to a slice, got: %T", s)) |
| 162 | } |
| 163 | return ptr, slice |
| 164 | } |
| 165 | |
| 166 | // getSlice checks s is a slice, returning the slice as a reflect.Value. |
| 167 | func getSlice(s interface{}) (slice reflect.Value) { |