Debian Codegraph @

execution/func_contains.go

raw symbols SCIP
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 "github.com/tomwright/dasel/v3/modelscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/"
7 )
8
9 // FuncContains is a function that returns the highest number.
10 var FuncContainsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/FuncContains. = NewFuncscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/NewFunc().(
11 "contains",
12 func(ctxscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/FuncContains: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`/FuncContains: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`/FuncContains: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) {
13 var containsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/FuncContains:contains. bool
14
15 target := argsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/FuncContains:args.[0]
16
17 length, err := datascip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/FuncContains:data..SliceLenscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#SliceLen().()
18 if err != nil {
19 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().("error getting slice length: %w", err)
20 }
21
22 for i := 0; i < length; i++ {
23 v, err := datascip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/FuncContains:data..GetSliceIndexscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#GetSliceIndex().(i)
24 if err != nil {
25 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().("error getting slice index %d: %w", i, err)
26 }
27 matches, err := v.Equalscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#Equal().(target)
28 if err != nil {
29 continue
30 }
31 matchesBool, err := matches.BoolValuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#BoolValue().()
32 if err != nil {
33 return nil, err
34 }
35 if matchesBool {
36 containsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/FuncContains:contains. = true
37 break
38 }
39 }
40
41 return modelscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/.NewBoolValuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/NewBoolValue().(containsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/FuncContains:contains.), nil
42 },
43 ValidateArgsExactlyscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/ValidateArgsExactly().(1),
44 )