| 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 | // FuncFlatten is a function that flattens a nested array by one level. |
| 11 | var FuncFlattenscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/FuncFlatten. = NewFuncscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/NewFunc().( |
| 12 | "flatten", |
| 13 | func(ctxscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/FuncFlatten: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`/FuncFlatten: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`/FuncFlatten: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 | var inputscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/FuncFlatten:input. *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# |
| 15 | if len(argsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/FuncFlatten:args.) == 1 { |
| 16 | inputscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/FuncFlatten:input. = argsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/FuncFlatten:args.[0] |
| 17 | } else { |
| 18 | inputscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/FuncFlatten:input. = datascip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/FuncFlatten:data. |
| 19 | } |
| 20 | |
| 21 | if !inputscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/FuncFlatten:input..IsSlicescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#IsSlice().() { |
| 22 | 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().("flatten expects an array, got %s", inputscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/FuncFlatten:input..Typescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#Type().().Stringscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Type#String().()) |
| 23 | } |
| 24 | |
| 25 | res := modelscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/.NewSliceValuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/NewSliceValue().() |
| 26 | if err := inputscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/FuncFlatten:input..RangeSlicescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#RangeSlice().(func(iscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/FuncFlatten:i. int, valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/FuncFlatten:value. *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 { |
| 27 | if valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/FuncFlatten:value..IsSlicescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#IsSlice().() { |
| 28 | return valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/FuncFlatten:value..RangeSlicescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#RangeSlice().(func(jscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/FuncFlatten:j. int, innerscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/FuncFlatten:inner. *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 { |
| 29 | return res.Appendscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#Append().(innerscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/FuncFlatten:inner.) |
| 30 | }) |
| 31 | } |
| 32 | return res.Appendscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#Append().(valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/FuncFlatten:value.) |
| 33 | }); err != nil { |
| 34 | return nil, err |
| 35 | } |
| 36 | |
| 37 | return res, nil |
| 38 | }, |
| 39 | ValidateArgsMaxscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/ValidateArgsMax().(1), |
| 40 | ) |