Len returns the length of the value.
()
| 318 | |
| 319 | // Len returns the length of the value. |
| 320 | func (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 | |
| 345 | func (v *Value) Copy() (*Value, error) { |
| 346 | switch v.Type() { |