Debian Codegraph @

api.go

raw symbols SCIP
1 // Package dasel contains everything you'll need to use dasel from a go application.
2 package daselscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3`/
3
4 import (
5 "contextscip-go gomod github.com/golang/go/src go1.25 context/"
6 "github.com/tomwright/dasel/v3/executionscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/"
7 "github.com/tomwright/dasel/v3/modelscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/"
8 )
9
10 // Query queries the data using the selector and returns the results.
11 func Queryscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3`/Query().(ctx contextscip-go gomod github.com/golang/go/src go1.25 context/.Contextscip-go gomod github.com/golang/go/src go1.25 context/Context#, data any, selector string, opts ...executionscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/.ExecuteOptionFnscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/ExecuteOptionFn#) ([]*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#, int, error) {
12 options := executionscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/.NewOptionsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/NewOptions().(opts...)
13 val := modelscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/.NewValuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/NewValue().(data)
14 out, err := executionscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/.ExecuteSelectorscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/ExecuteSelector().(ctx, selector, val, options)
15 if err != nil {
16 return nil, 0, err
17 }
18
19 if out.IsBranchscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#IsBranch().() || out.IsSpreadscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#IsSpread().() {
20 res := make([]*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#, 0)
21 if err := out.RangeSlicescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#RangeSlice().(func(i int, v *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 {
22 res = append(res, v)
23 return nil
24 }); err != nil {
25 return nil, 0, err
26 }
27 return res, len(res), nil
28 }
29
30 return []*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#{out}, 1, nil
31 }
32
33 // Select queries the data using the selector and returns the results as native Go types.
34 // Ordering within maps is not guaranteed.
35 func Selectscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3`/Select().(ctx contextscip-go gomod github.com/golang/go/src go1.25 context/.Contextscip-go gomod github.com/golang/go/src go1.25 context/Context#, data any, selector string, opts ...executionscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/.ExecuteOptionFnscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/ExecuteOptionFn#) (any, int, error) {
36 res, count, err := Queryscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3`/Query().(ctx, data, selector, opts...)
37 if err != nil {
38 return nil, 0, err
39 }
40 out := make([]any, 0)
41 for _, v := range res {
42 goValue, err := v.GoValuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#GoValue().()
43 if err != nil {
44 return nil, 0, err
45 }
46 out = append(out, goValue)
47 }
48 return out, count, err
49 }
50
51 // Modify runs the query against the given data and updates it in-place.
52 // Given data must be a pointer to a mutable data structure.
53 func Modifyscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3`/Modify().(ctx contextscip-go gomod github.com/golang/go/src go1.25 context/.Contextscip-go gomod github.com/golang/go/src go1.25 context/Context#, data any, selector string, newValue any, opts ...executionscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/.ExecuteOptionFnscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/ExecuteOptionFn#) (int, error) {
54 res, count, err := Queryscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3`/Query().(ctx, data, selector, opts...)
55 if err != nil {
56 return 0, err
57 }
58 for _, v := range res {
59 if err := v.Setscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#Set().(modelscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/.NewValuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/NewValue().(newValue)); err != nil {
60 return 0, err
61 }
62 }
63 return count, nil
64 }