(e ast.IndexExpr)
| 88 | } |
| 89 | |
| 90 | func 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 | } |
no test coverage detected