| 1 | package modelscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/ |
| 2 | |
| 3 | import "fmtscip-go gomod github.com/golang/go/src go1.25 fmt/" |
| 4 | |
| 5 | // GoValue returns the value as a native Go value. |
| 6 | func (v *Valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#) GoValuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#GoValue().() (any, error) { |
| 7 | var res any |
| 8 | var err error |
| 9 | |
| 10 | switch v.Typescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#Type().() { |
| 11 | case TypeStringscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/TypeString.: |
| 12 | res, err = v.StringValuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#StringValue().() |
| 13 | case TypeIntscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/TypeInt.: |
| 14 | res, err = v.IntValuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#IntValue().() |
| 15 | case TypeFloatscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/TypeFloat.: |
| 16 | res, err = v.FloatValuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#FloatValue().() |
| 17 | case TypeBoolscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/TypeBool.: |
| 18 | res, err = v.BoolValuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#BoolValue().() |
| 19 | case TypeMapscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/TypeMap.: |
| 20 | m := make(map[string]any) |
| 21 | err = v.RangeMapscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#RangeMap().(func(k string, v *Valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#) error { |
| 22 | val, err := v.GoValuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#GoValue().() |
| 23 | if err != nil { |
| 24 | return err |
| 25 | } |
| 26 | m[k] = val |
| 27 | return nil |
| 28 | }) |
| 29 | res = m |
| 30 | case TypeSlicescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/TypeSlice.: |
| 31 | s := make([]any, 0) |
| 32 | err = v.RangeSlicescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#RangeSlice().(func(i int, v *Valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#) error { |
| 33 | val, err := v.GoValuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#GoValue().() |
| 34 | if err != nil { |
| 35 | return err |
| 36 | } |
| 37 | s = append(s, val) |
| 38 | return nil |
| 39 | }) |
| 40 | res = s |
| 41 | case TypeUnknownscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/TypeUnknown.: |
| 42 | res = nil |
| 43 | err = fmtscip-go gomod github.com/golang/go/src go1.25 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.25 fmt/Errorf().("cannot convert unknown type to Go value") |
| 44 | case TypeNullscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/TypeNull.: |
| 45 | res = nil |
| 46 | default: |
| 47 | err = fmtscip-go gomod github.com/golang/go/src go1.25 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.25 fmt/Errorf().("unhandled type %v", v.Typescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#Type().()) |
| 48 | } |
| 49 | |
| 50 | return res, err |
| 51 | } |