| 1 | package executionscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/ |
| 2 | |
| 3 | import ( |
| 4 | "contextscip-go gomod github.com/golang/go/src go1.25 context/" |
| 5 | "fmtscip-go gomod github.com/golang/go/src go1.25 fmt/" |
| 6 | |
| 7 | "github.com/tomwright/dasel/v3/modelscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/" |
| 8 | ) |
| 9 | |
| 10 | // FuncGet is a function returns the value at the given key/index. |
| 11 | var FuncGetscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/FuncGet. = NewFuncscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/NewFunc().( |
| 12 | "get", |
| 13 | func(ctxscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/FuncGet:ctx. contextscip-go gomod github.com/golang/go/src go1.25 context/.Contextscip-go gomod github.com/golang/go/src go1.25 context/Context#, datascip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/FuncGet:data. *modelscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/.Valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#, argsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/FuncGet:args. modelscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/.Valuesscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Values#) (*modelscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/.Valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#, error) { |
| 14 | |
| 15 | arg := argsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/FuncGet:args.[0] |
| 16 | |
| 17 | switch arg.Typescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#Type().() { |
| 18 | case modelscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/.TypeIntscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/TypeInt.: |
| 19 | index, err := arg.IntValuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#IntValue().() |
| 20 | if err != nil { |
| 21 | return nil, err |
| 22 | } |
| 23 | return datascip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/FuncGet:data..GetSliceIndexscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#GetSliceIndex().(int(index)) |
| 24 | case modelscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/.TypeStringscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/TypeString.: |
| 25 | key, err := arg.StringValuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#StringValue().() |
| 26 | if err != nil { |
| 27 | return nil, err |
| 28 | } |
| 29 | return datascip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/FuncGet:data..GetMapKeyscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#GetMapKey().(key) |
| 30 | default: |
| 31 | return nil, fmtscip-go gomod github.com/golang/go/src go1.25 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.25 fmt/Errorf().("get expects string or int argument") |
| 32 | } |
| 33 | }, |
| 34 | ValidateArgsExactlyscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/ValidateArgsExactly().(1), |
| 35 | ) |