MCPcopy Index your code
hub / github.com/expr-lang/expr / ExamplePatch

Function ExamplePatch

expr_test.go:612–637  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

610}
611
612func ExamplePatch() {
613 program, err := expr.Compile(
614 `greet.you.world + "!"`,
615 expr.Patch(&patcher{}),
616 )
617 if err != nil {
618 fmt.Printf("%v", err)
619 return
620 }
621
622 env := map[string]any{
623 "greet": "Hello",
624 "get": func(a, b string) string {
625 return a + ", " + b
626 },
627 }
628
629 output, err := expr.Run(program, env)
630 if err != nil {
631 fmt.Printf("%v", err)
632 return
633 }
634 fmt.Printf("%v", output)
635
636 // Output: Hello, you, world!
637}
638
639func ExampleWithContext() {
640 env := map[string]any{

Callers

nothing calls this directly

Calls 4

CompileFunction · 0.92
PatchFunction · 0.92
RunFunction · 0.92
PrintfMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…