Expression language and expression evaluation for Go
8,009
stars
1,024
commits
Go
primary language
Jul 7, 2026
updated
Expr is a Go-centric expression language designed to deliver dynamic configurations with unparalleled accuracy, safety, and speed. Expr combines simple syntax with powerful features for ease of use:
// Allow only admins and moderators to moderate comments.
user.Group in ["admin", "moderator"] || user.Id == comment.UserId
// Determine whether the request is in the permitted time window.
request.Time - resource.Age < duration("24h")
// Ensure all tweets are less than 240 characters.
all(tweets, len(.Content) <= 240)
Expr is a safe, fast, and intuitive expression evaluator optimized for the Go language. Here are its standout features:
out, err := expr.Compile(`name + age`)
// err: invalid operation + (mismatched types string and int)
// | name + age
// | .....^
all, none, any, one, filter, and map are provided out-of-the-box.go get github.com/expr-lang/expr
package main
import (
"fmt"
"github.com/expr-lang/expr"
)
func main() {
env := map[string]interface{}{
"greet": "Hello, %v!",
"names": []string{"world", "you"},
"sprintf": fmt.Sprintf,
}
code := `sprintf(greet, names[0])`
program, err := expr.Compile(code, expr.Env(env))
if err != nil {
panic(err)
}
output, err := expr.Run(program, env)
if err != nil {
panic(err)
}
fmt.Println(output)
}
package main
import (
"fmt"
"github.com/expr-lang/expr"
)
type Tweet struct {
Len int
}
type Env struct {
Tweets []Tweet
}
func main() {
code := `all(Tweets, {.Len <= 240})`
program, err := expr.Compile(code, expr.Env(Env{}))
if err != nil {
panic(err)
}
env := Env{
Tweets: []Tweet{{42}, {98}, {69}},
}
output, err := expr.Run(program, env)
if err != nil {
panic(err)
}
fmt.Println(output)
}

(top 30 of 85)
Go
99.9%
Expression language and expression evaluation for Go
8,009
stars
1,024
commits
Go
primary language
Jul 7, 2026
updated
Expr is a Go-centric expression language designed to deliver dynamic configurations with unparalleled accuracy, safety, and speed. Expr combines simple syntax with powerful features for ease of use:
// Allow only admins and moderators to moderate comments.
user.Group in ["admin", "moderator"] || user.Id == comment.UserId
// Determine whether the request is in the permitted time window.
request.Time - resource.Age < duration("24h")
// Ensure all tweets are less than 240 characters.
all(tweets, len(.Content) <= 240)
Expr is a safe, fast, and intuitive expression evaluator optimized for the Go language. Here are its standout features:
out, err := expr.Compile(`name + age`)
// err: invalid operation + (mismatched types string and int)
// | name + age
// | .....^
all, none, any, one, filter, and map are provided out-of-the-box.go get github.com/expr-lang/expr
package main
import (
"fmt"
"github.com/expr-lang/expr"
)
func main() {
env := map[string]interface{}{
"greet": "Hello, %v!",
"names": []string{"world", "you"},
"sprintf": fmt.Sprintf,
}
code := `sprintf(greet, names[0])`
program, err := expr.Compile(code, expr.Env(env))
if err != nil {
panic(err)
}
output, err := expr.Run(program, env)
if err != nil {
panic(err)
}
fmt.Println(output)
}
package main
import (
"fmt"
"github.com/expr-lang/expr"
)
type Tweet struct {
Len int
}
type Env struct {
Tweets []Tweet
}
func main() {
code := `all(Tweets, {.Len <= 240})`
program, err := expr.Compile(code, expr.Env(Env{}))
if err != nil {
panic(err)
}
env := Env{
Tweets: []Tweet{{42}, {98}, {69}},
}
output, err := expr.Run(program, env)
if err != nil {
panic(err)
}
fmt.Println(output)
}

(top 30 of 85)
Go
99.9%