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

Method Len

model/value.go:320–343  ·  view source on GitHub ↗

Len returns the length of the value.

()

Source from the content-addressed store, hash-verified

318
319// Len returns the length of the value.
320func (v *Value) Len() (int, error) {
321 var l int
322 var err error
323
324 switch {
325 case v.IsSlice():
326 l, err = v.SliceLen()
327 case v.IsMap():
328 l, err = v.MapLen()
329 case v.IsString():
330 l, err = v.StringLen()
331 default:
332 err = ErrUnexpectedTypes{
333 Expected: []Type{TypeSlice, TypeMap, TypeString},
334 Actual: v.Type(),
335 }
336 }
337
338 if err != nil {
339 return l, err
340 }
341
342 return l, nil
343}
344
345func (v *Value) Copy() (*Value, error) {
346 switch v.Type() {

Callers 9

SliceLenMethod · 0.45
GetSliceIndexMethod · 0.45
SetSliceIndexMethod · 0.45
TestValue_LenFunction · 0.45
TestValue_Len_ErrorFunction · 0.45
TestValues_ToSliceValueFunction · 0.45
readNumberMethod · 0.45
ensureMapAtFunction · 0.45
func_len.goFile · 0.45

Calls 7

IsSliceMethod · 0.95
SliceLenMethod · 0.95
IsMapMethod · 0.95
MapLenMethod · 0.95
IsStringMethod · 0.95
StringLenMethod · 0.95
TypeMethod · 0.95

Tested by 3

TestValue_LenFunction · 0.36
TestValue_Len_ErrorFunction · 0.36
TestValues_ToSliceValueFunction · 0.36