MCPcopy
hub / github.com/TomWright/dasel / UnpackUntilAddressable

Method UnpackUntilAddressable

model/value.go:239–251  ·  view source on GitHub ↗

UnpackUntilAddressable unpacks the reflect value until it is addressable.

()

Source from the content-addressed store, hash-verified

237
238// UnpackUntilAddressable unpacks the reflect value until it is addressable.
239func (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.
254func (v *Value) UnpackUntilKind(k reflect.Kind) (*Value, error) {

Callers 1

SetMethod · 0.95

Calls 2

NewValueFunction · 0.85
KindMethod · 0.80

Tested by

no test coverage detected