MCPcopy Create free account
hub / github.com/cel-expr/cel-go / report

Function report

codelab/codelab.go:196–220  ·  view source on GitHub ↗

report prints out the result of evaluation in human-friendly terms.

(result ref.Val, details *cel.EvalDetails, err error)

Source from the content-addressed store, hash-verified

194
195// report prints out the result of evaluation in human-friendly terms.
196func report(result ref.Val, details *cel.EvalDetails, err error) {
197 fmt.Println("------ result ------")
198 if err != nil {
199 fmt.Printf("error: %s\n", err)
200 } else {
201 fmt.Printf("value: %v (%T)\n", result, result)
202 }
203 if details != nil {
204 fmt.Printf("\n------ eval states ------\n")
205 state := details.State()
206 stateIDs := state.IDs()
207 ids := make([]int, len(stateIDs), len(stateIDs))
208 for i, id := range stateIDs {
209 ids[i] = int(id)
210 }
211 sort.Ints(ids)
212 for _, id := range ids {
213 v, found := state.Value(int64(id))
214 if !found {
215 continue
216 }
217 fmt.Printf("%d: %v (%T)\n", id, v, v)
218 }
219 }
220}
221
222// mapContainsKeyValue implements the custom function:
223//

Callers 1

evalFunction · 0.70

Calls 3

StateMethod · 0.80
IDsMethod · 0.65
ValueMethod · 0.65

Tested by

no test coverage detected