{"modulePath":"github.com/expr-lang/expr","version":"v1.18.1","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package expr\n\n## Functions\n\n```go\nfunc Compile(input string, ops ...Option) (*vm.Program, error)\n```\nCompile parses and compiles given input expression to bytecode program.\n\n```go\nfunc Eval(input string, env any) (any, error)\n```\nEval parses, compiles and runs given input.\n\n```go\nfunc Run(program *vm.Program, env any) (any, error)\n```\nRun evaluates given bytecode program.\n\n## Types\n\n```go\ntype Option func(c *conf.Config)\n```\nOption for configuring config.\n\n```go\nfunc AllowUndefinedVariables() Option\n```\nAllowUndefinedVariables allows to use undefined variables inside expressions. This can be used with expr.Env option to partially define a few variables.\n\n```go\nfunc AsAny() Option\n```\nAsAny tells the compiler to expect any result.\n\n```go\nfunc AsBool() Option\n```\nAsBool tells the compiler to expect a boolean result.\n\n```go\nfunc AsFloat64() Option\n```\nAsFloat64 tells the compiler to expect a float64 result.\n\n```go\nfunc AsInt() Option\n```\nAsInt tells the compiler to expect an int result.\n\n```go\nfunc AsInt64() Option\n```\nAsInt64 tells the compiler to expect an int64 result.\n\n```go\nfunc AsKind(kind reflect.Kind) Option\n```\nAsKind tells the compiler to expect kind of the result.\n\n```go\nfunc ConstExpr(fn string) Option\n```\nConstExpr defines func expression as constant. If all argument to this function is constants, then it can be replaced by result of this func call on compile step.\n\n```go\nfunc DisableAllBuiltins() Option\n```\nDisableAllBuiltins disables all builtins.\n\n```go\nfunc DisableBuiltin(name string) Option\n```\nDisableBuiltin disables builtin function.\n\n```go\nfunc DisableIfOperator() Option\n```\nDisableIfOperator disables the \\`if ... else ...\\` operator syntax so a custom function named \\`if(...)\\` can be used without conflicts.\n\n```go\nfunc DisableShortCircuit() Option\n```\nDisableShortCircuit turns short circuit off.\n\n```go\nfunc EnableBuiltin(name string) Option\n```\nEnableBuiltin enables builtin function.\n\n```go\nfunc Env(env any) Option\n```\nEnv specifies expected input of env for type checks. If struct is passed, all fields will be treated as variables, as well as all fields of embedded structs and struct itself. If map is passed, all items will be treated as variables. Methods defined on this type will be available as functions.\n\n```go\nfunc Function(name string, fn func(params ...any) (any, error), types ...any) Option\n```\nFunction adds function to list of functions what will be available in expressions.\n\n```go\nfunc MaxNodes(n uint) Option\n```\nMaxNodes sets the maximum number of nodes allowed in the expression. By default, the maximum number of nodes is conf.DefaultMaxNodes. If MaxNodes is set to 0, the node budget check is disabled.\n\n```go\nfunc Operator(operator string, fn ...string) Option\n```\nOperator allows to replace a binary operator with a function.\n\n```go\nfunc Optimize(b bool) Option\n```\nOptimize turns optimizations on or off.\n\n```go\nfunc Patch(visitor ast.Visitor) Option\n```\nPatch adds visitor to list of visitors what will be applied before compiling AST to bytecode.\n\n```go\nfunc Timezone(name string) Option\n```\nTimezone sets default timezone for date() and now() builtin functions.\n\n```go\nfunc WarnOnAny() Option\n```\nWarnOnAny tells the compiler to warn if expression return any type.\n\n```go\nfunc WithContext(name string) Option\n```\nWithContext passes context to all functions calls with a context.Context argument.\n\n","path":"github.com/expr-lang/expr","name":"expr","synopsis":"","isRedistributable":true}
