package main import ( "fmt" "github.com/antonmedv/expr" ) func main() { env := map[string]any{} options := []expr.Option{ expr.Env(env), expr.AllowUndefinedVariables(), } program, err := expr.Compile("(a - b + c) / d", options...) if err != nil { panic(err) } res, err := expr.Run(program, map[string]any{ "a": 1, "b": 2, "c": 3, "d": 4, }) if err != nil { panic(err) } fmt.Printf("%v\n", res) }