https://github.com/stevencyb/goeval
A GoLang library for simple expression evaluation.
https://github.com/stevencyb/goeval
Last synced: 7 days ago
JSON representation
A GoLang library for simple expression evaluation.
- Host: GitHub
- URL: https://github.com/stevencyb/goeval
- Owner: StevenCyb
- License: mit
- Created: 2024-04-09T08:23:26.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-04-10T09:54:39.000Z (over 1 year ago)
- Last Synced: 2024-04-10T11:36:28.828Z (over 1 year ago)
- Language: Go
- Homepage:
- Size: 7.81 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# goeval
A GoLang library for simple expression evaluation.
```go
expr.Eval("true && true") # true
expr.Eval("2+3") # 5
expr.Eval("1+3>3") # true
expr.Eval("('fo'!='bar')&&(2!=3)") # true
```[](https://github.com/StevenCyb/goeval/releases/latest)

## Logical Operation
Supported logical operations are `&&` and `||`.
* On text, `"true"` or `'true'` (case insensitive) is `true`, else `false`
* On numbers greater zero is `true`, else `false`## Comparison Operation
Supported comparisons are `==`, `!=`, `<`, `>`, `<=` or `>=`.
While equal and not equal directly uses the value. Greater(equal) and smaller(equal) will behave different:
* On boolean a `0` and `1` is used (`true>0` = `true`, `false>0` = `false`).
* On text the length is used (`"hello">"hey"` = `true`).## Arithmetic Operation
Supported arithmetics are `+`, `-`, `*`, `/` and `%`.
* On boolean a `0` and `1` is used (`true+0` = `1`, `false+0` = `0`).
* On text the length is used (`"foo"+"bar"` = `6`).## Context
Context can be used to group a part of the expression to prioritize the evaluation.