mirror of
https://github.com/hanzoai/expr.git
synced 2026-09-24 16:58:58 +00:00
4e61df139ba36e1dfb830578718e4f95a2fa7602
Expr

Expr is an engine that can evaluate expressions.
The purpose of the package is to allow users to use expressions inside configuration for more complex logic. It is a perfect candidate for the foundation of a business rule engine. The idea is to let configure things in a dynamic way without recompile of a program:
# Get the special price if
user.Group in ["good_customers", "collaborator"]
# Promote article to the homepage when
len(article.Comments) > 100 and article.Category not in ["misc"]
# Send an alert when
product.Stock < 15
Inspired by
- Symfony's The ExpressionLanguage component,
- Rob Pike's talk Lexical Scanning in Go.
Features
- Works with any valid Go object (structs, maps, etc)
- Strict mode with type checks
- User-friendly error messages
unclosed "(" (boo + bar] ----------^ - Reasonable set of basic operators
- Fast (faster otto and goja, see bench)
Install
go get -u github.com/antonmedv/expr
Documentation
- See
for developer documentation,
- See The Expression Syntax page to learn the syntax of the Expr expressions.
License
MIT
Languages
Go
93.6%
txt
6.2%
JavaScript
0.1%