MCPcopy
hub / github.com/TomWright/dasel / indexExprExecutor

Function indexExprExecutor

execution/execute_array.go:90–105  ·  view source on GitHub ↗
(e ast.IndexExpr)

Source from the content-addressed store, hash-verified

88}
89
90func indexExprExecutor(e ast.IndexExpr) (expressionExecutor, error) {
91 return func(ctx context.Context, options *Options, data *model.Value) (*model.Value, error) {
92 ctx = WithExecutorID(ctx, "indexExpr")
93 indexE, err := ExecuteAST(ctx, e.Index, data, options)
94 if err != nil {
95 return nil, fmt.Errorf("error evaluating index expression: %w", err)
96 }
97
98 index, err := indexE.IntValue()
99 if err != nil {
100 return nil, fmt.Errorf("error getting index int value: %w", err)
101 }
102
103 return data.GetSliceIndex(int(index))
104 }, nil
105}

Callers 1

exprExecutorFunction · 0.85

Calls 4

WithExecutorIDFunction · 0.85
ExecuteASTFunction · 0.85
IntValueMethod · 0.80
GetSliceIndexMethod · 0.80

Tested by

no test coverage detected