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

Function report

codelab/solution/codelab.go:437–461  ·  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

435
436// report prints out the result of evaluation in human-friendly terms.
437func report(result ref.Val, details *cel.EvalDetails, err error) {
438 fmt.Println("------ result ------")
439 if err != nil {
440 fmt.Printf("error: %s\n", err)
441 } else {
442 fmt.Printf("value: %v (%T)\n", result, result)
443 }
444 if details != nil {
445 fmt.Printf("\n------ eval states ------\n")
446 state := details.State()
447 stateIDs := state.IDs()
448 ids := make([]int, len(stateIDs), len(stateIDs))
449 for i, id := range stateIDs {
450 ids[i] = int(id)
451 }
452 sort.Ints(ids)
453 for _, id := range ids {
454 v, found := state.Value(int64(id))
455 if !found {
456 continue
457 }
458 fmt.Printf("%d: %v (%T)\n", id, v, v)
459 }
460 }
461}
462
463// mapContainsKeyValue implements the custom function:
464//

Callers 1

evalFunction · 0.70

Calls 3

StateMethod · 0.80
IDsMethod · 0.65
ValueMethod · 0.65

Tested by

no test coverage detected