Documentation
¶
Overview ¶
Package expr provides a script engine implementation using the Expr expression language (https://github.com/expr-lang/expr). Expr is a fast, type-safe expression evaluator that supports variables, functions, and a rich set of built-in operators.
Construction:
eng, _ := expr.New(ctx)
eng.Init(ctx)
eng.RegisterGlobal("name", "world")
result, _ := eng.ExecuteString(ctx, "greet", `"Hello " + name`)
The engine supports hot-reload via StartWatch/StopWatch when the bound Source implements the Watcher interface.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrExprEngineNotInitialized is returned when an operation is invoked // before Init or after Close. ErrExprEngineNotInitialized = errors.New("expr engine not initialized") // ErrExprEngineAlreadyInitialized is returned when Init is called on an // already-initialized engine. ErrExprEngineAlreadyInitialized = errors.New("expr engine already initialized") // ErrExprCompileFailed is returned when compiling an expression fails. ErrExprCompileFailed = errors.New("expr compile failed") // ErrExprNoExpressionLoaded is returned when Execute is called but no // expression has been loaded. ErrExprNoExpressionLoaded = errors.New("expr no expression loaded") // ErrExprRunFailed is returned when evaluating an expression fails. ErrExprRunFailed = errors.New("expr run failed") // ErrExprFunctionNotFound is returned when CallFunction cannot find the // named function. ErrExprFunctionNotFound = errors.New("expr function not found") // ErrExprGlobalNotFound is returned when GetGlobal cannot find the named // variable. ErrExprGlobalNotFound = errors.New("expr global not found") )
Sentinel errors returned by the Expr engine.
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.