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

Method UnpackKinds

model/value.go:187–203  ·  view source on GitHub ↗

UnpackKinds unpacks the reflect value until it no longer matches the given kinds.

(kinds ...reflect.Kind)

Source from the content-addressed store, hash-verified

185
186// UnpackKinds unpacks the reflect value until it no longer matches the given kinds.
187func (v *Value) UnpackKinds(kinds ...reflect.Kind) *Value {
188 val := v
189 for val.isDaselValue() {
190 var err error
191 val, err = val.daselValue()
192 if err != nil {
193 panic(err)
194 }
195 }
196 res := val.value
197 for {
198 if !slices.Contains(kinds, res.Kind()) || res.IsNil() {
199 return NewValue(res)
200 }
201 res = res.Elem()
202 }
203}
204
205type ErrCouldNotUnpackToType struct {
206 Type reflect.Type

Callers 15

IsScalarMethod · 0.95
IsSliceMethod · 0.95
AppendMethod · 0.95
SliceLenMethod · 0.95
GetSliceIndexMethod · 0.95
SetSliceIndexMethod · 0.95
isStandardMapMethod · 0.95
isDencodingMapMethod · 0.95
IsNullMethod · 0.95
IsStringMethod · 0.95
StringValueMethod · 0.95
IsIntMethod · 0.95

Calls 4

NewValueFunction · 0.85
isDaselValueMethod · 0.80
daselValueMethod · 0.80
KindMethod · 0.80

Tested by

no test coverage detected