UnpackUntilAddressable unpacks the reflect value until it is addressable.
()
| 237 | |
| 238 | // UnpackUntilAddressable unpacks the reflect value until it is addressable. |
| 239 | func (v *Value) UnpackUntilAddressable() (*Value, error) { |
| 240 | res := v.value |
| 241 | for { |
| 242 | if res.CanAddr() { |
| 243 | return NewValue(res), nil |
| 244 | } |
| 245 | if res.Kind() == reflect.Interface || res.Kind() == reflect.Pointer && !res.IsNil() { |
| 246 | res = res.Elem() |
| 247 | continue |
| 248 | } |
| 249 | return nil, fmt.Errorf("could not unpack addressable value") |
| 250 | } |
| 251 | } |
| 252 | |
| 253 | // UnpackUntilKind unpacks the reflect value until it matches the given kind. |
| 254 | func (v *Value) UnpackUntilKind(k reflect.Kind) (*Value, error) { |