A Go library for evaluating arbitrary arithmetic, string, and logic expressions with variable access and custom functions.
goval is a Go library for evaluating arbitrary arithmetic, string, and logic expressions. It provides a flexible syntax for accessing variables and calling custom functions, making it suitable for dynamic expression evaluation in production systems.
Go developers building applications that require runtime expression evaluation, such as configuration systems, rule engines, or dynamic calculators.
Developers choose goval for its intuitive syntax, high performance through a single-pass parser, and robust type handling with automatic numeric conversion, avoiding unnecessary complexity like struct support.
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.
Supports dot and bracket notation for accessing nested variables in maps, as shown with examples like `var.field` and `var["field"]`, making expressions readable and flexible.
Uses a single-pass parser without an intermediate AST, leading to reduced code size and fast evaluation, which is highlighted in the comparison with govaluate for optimized performance.
Automatically converts between int and float64 without precision loss and supports mixed arrays and objects, demonstrated in the type system section for seamless numeric operations.
Allows custom functions for advanced operations like regex matching, with clear examples such as implementing `matches("text", "[a-z]+")` to extend functionality.
Explicitly omits structs to avoid complexity, limiting integration with Go's common struct-based data models and requiring workarounds with maps.
Treats dates as plain strings without special handling, forcing developers to implement custom functions for any date-related logic, which adds overhead.
In ternary operators, all operands are always evaluated, as noted in the documentation, which can lead to unnecessary computations or side effects in conditional expressions.