expr

package
v0.4.13 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 2, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

expr language support.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Eval

func Eval(s string, t any) (any, error)

Compile and Run Expr expression.

See https://expr-lang.org/docs/language-definition.

Types

type Expr

type Expr[T any] struct {
	// contains filtered or unexported fields
}

func Compile

func Compile[T any](s string) (*Expr[T], error)

Compile Expr expression.

If T is map, use CompileEnv instead.

The compiled *Expr can be reused concurrently.

See https://expr-lang.org/docs/language-definition.

func CompileEnv

func CompileEnv[T any](s string, env T) (*Expr[T], error)

Compile Expr expression with Env example.

The compiled *Expr can be reused concurrently.

See https://expr-lang.org/docs/language-definition.

func MustCompile

func MustCompile[T any](s string) *Expr[T]

Compile Expr expression.

If T is map, use MustCompileEnv instead.

The compiled *Expr can be reused concurrently.

See https://expr-lang.org/docs/language-definition.

func MustCompileEnv

func MustCompileEnv[T any](s string, env T) *Expr[T]

Compile Expr expression with Env example.

The compiled *Expr can be reused concurrently.

See https://expr-lang.org/docs/language-definition.

func (*Expr[T]) Eval

func (e *Expr[T]) Eval(env T) (any, error)

type PooledExpr

type PooledExpr[T any] struct {
	// contains filtered or unexported fields
}

func NewPooledExpr

func NewPooledExpr[T any](cacheSize int) *PooledExpr[T]

Create PooledExpr.

The compiled *PooledExpr can be reused concurrently.

T can be struct or map, but the overall structure must be the same (e.g., map with same kinds of keys).

cacheSize: max number of *Expr in cache.

func (*PooledExpr[T]) Eval

func (e *PooledExpr[T]) Eval(s string, env T) (any, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL