| 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 | "stringsscip-go gomod github.com/golang/go/src go1.25 strings/" |
| 7 | |
| 8 | "github.com/tomwright/dasel/v3/modelscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/" |
| 9 | ) |
| 10 | |
| 11 | // FuncJoin is a function that joins the given data or args to a string. |
| 12 | var FuncJoinscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/FuncJoin. = NewFuncscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/NewFunc().( |
| 13 | "join", |
| 14 | func(ctxscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/FuncJoin: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`/FuncJoin: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`/FuncJoin: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) { |
| 15 | separator, err := argsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/FuncJoin:args.[0].StringValuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#StringValue().() |
| 16 | if err != nil { |
| 17 | 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().("join expects a string separator as the first argument: %w", err) |
| 18 | } |
| 19 | |
| 20 | var valuesToJoinscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/FuncJoin:valuesToJoin. []string |
| 21 | |
| 22 | if len(argsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/FuncJoin:args.) == 2 && argsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/FuncJoin:args.[1].IsSlicescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#IsSlice().() { |
| 23 | if err := argsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/FuncJoin:args.[1].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`/FuncJoin:i. int, valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/FuncJoin: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 { |
| 24 | strVal, err := valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/FuncJoin:value..StringValuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#StringValue().() |
| 25 | if err != nil { |
| 26 | return fmtscip-go gomod github.com/golang/go/src go1.25 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.25 fmt/Errorf().("could not read string value of index %d: %w", iscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/FuncJoin:i., err) |
| 27 | } |
| 28 | valuesToJoinscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/FuncJoin:valuesToJoin. = append(valuesToJoinscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/FuncJoin:valuesToJoin., strVal) |
| 29 | return nil |
| 30 | }); err != nil { |
| 31 | return nil, err |
| 32 | } |
| 33 | } else if len(argsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/FuncJoin:args.) > 1 { |
| 34 | // Join the args |
| 35 | for i := 1; i < len(argsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/FuncJoin:args.); i++ { |
| 36 | strVal, err := argsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/FuncJoin:args.[i].StringValuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#StringValue().() |
| 37 | if err != nil { |
| 38 | 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().("could not read string value of argument index %d: %w", i, err) |
| 39 | } |
| 40 | valuesToJoinscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/FuncJoin:valuesToJoin. = append(valuesToJoinscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/FuncJoin:valuesToJoin., strVal) |
| 41 | } |
| 42 | } else { |
| 43 | if err := datascip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/FuncJoin:data..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`/FuncJoin:i. int, valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/FuncJoin: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 { |
| 44 | strVal, err := valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/FuncJoin:value..StringValuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#StringValue().() |
| 45 | if err != nil { |
| 46 | return fmtscip-go gomod github.com/golang/go/src go1.25 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.25 fmt/Errorf().("could not read string value of index %d: %w", iscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/FuncJoin:i., err) |
| 47 | } |
| 48 | valuesToJoinscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/FuncJoin:valuesToJoin. = append(valuesToJoinscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/FuncJoin:valuesToJoin., strVal) |
| 49 | return nil |
| 50 | }); err != nil { |
| 51 | return nil, err |
| 52 | } |
| 53 | } |
| 54 | |
| 55 | joined := stringsscip-go gomod github.com/golang/go/src go1.25 strings/.Joinscip-go gomod github.com/golang/go/src go1.25 strings/Join().(valuesToJoinscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/FuncJoin:valuesToJoin., separator) |
| 56 | |
| 57 | return modelscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/.NewStringValuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/NewStringValue().(joined), nil |
| 58 | }, |
| 59 | ValidateArgsMinscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/ValidateArgsMin().(1), |
| 60 | ) |