github expr-lang/expr v1.17.0

13 hours ago

Expr is a Go-centric expression language designed to deliver dynamic configurations with unparalleled accuracy,
safety, and speed.

program, err := expr.Compile(`let foo = bar(); baz(foo, foo)`)

In this release:

This release added the biggest change to the Expr language: if-else expressions and sequential expressions. #736 e750878

if foo > 42 {
    assert(foo);
    calc(foo, foo / 2)
} else {
    calc(0, 0)
}

A sequence of expression may be separated by ; char. The last semicolon must be omitted. Expr returns the value of the
last expression in the sequence.

If-else is also expressions. Each if must have an else part. Result of if-else can be used as an expression:

let foo = if bar > 0 {
    process(bar)
} else {
    fallback()
};
foo + 42

Added:

  • Added ast.Find helper for easy AST searching. 579de74
  • Added compile node budget and memory limits (#762)
  • Added uniq() builtin (#705)
  • Added flatten() builtin (#684)
  • Added types pkg (#665 #667 #668)

Improvements:

Fixes:

  • Make sure get() returns nil for map[string]string on missing keys 435b79d
  • Fixed func calls with nil types value d63c3b5
  • Fixed AST printing of ops with precedence (#678)
  • Do not optimize filter() | map() if #index is used 35bdb68
  • Separated patching phases for patchers that require multiple passes. (#659)

Don't miss a new expr release

NewReleases is sending notifications on new releases.