A Go library for evaluating arbitrary expressions with support for parameters, custom functions, and extensible languages.
Gval is a Go library for evaluating arbitrary expressions, supporting parameters, arithmetic, logical operations, and custom extensions. It solves the need for dynamic expression evaluation in Go applications, such as configuring rules, validating inputs, or implementing domain-specific languages.
Go developers building applications that require dynamic expression evaluation, such as rule engines, configuration systems, or scripting interfaces.
Developers choose Gval for its extensibility, Go-like syntax, and performance optimizations, allowing them to create tailored expression languages without sacrificing efficiency.
Expression evaluation in golang
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Allows adding custom functions, operators, and selectors, enabling tailored expression languages as demonstrated with JSON Path integration for complex data access.
Supports parsing expressions once and reusing them for efficient repeated evaluation, with benchmarks showing nanosecond-level operations for constant expressions.
Uses Go operators, constants, and precedence rules, making it intuitive for Go developers to write and understand expressions without learning a new syntax.
Enables accessing fields and methods on struct parameters directly within expressions, though the README notes this comes with a performance trade-off.
Accessing struct fields and methods uses reflection, making expressions about four times slower than parameter-based access, as explicitly stated in the documentation.
Core language lacks advanced features like date handling or string manipulation without custom extensions, relying on external libraries such as gvalstrings or jsonpath.
Implementing custom selectors or functions requires implementing interfaces like SelectGVal, adding development time and complexity for non-trivial use cases.