Our great sponsors
-
If you want Python syntax, https://github.com/google/starlark-go is nice. It is the configuration language interpreter for Bazel, so it is well maintained and stable But that also means features, move slowly and some things that you would find in the standard library for CPython need to be grabbed from a different community maintained repo. It's also, in my opinion, a little less smooth moving back and forth between the scripting language and your code. Code. That said, both are great choices in my opinion. Some people like Lua. I'm sure I would like it if I wanted to spend time on it, but I'm already pretty comfortable with the other choices so I haven't.
-
expr
Discontinued Expression language and expression evaluation for Go [Moved to: https://github.com/expr-lang/expr] (by antonmedv)
We use https://github.com/antonmedv/expr at some other place for similar case, but there rules are bit simpler and this library seem to suit ideally for such simple "one line" conditions.
-
WorkOS
The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.
-
Googling suggests https://github.com/robertkrimen/otto which allows scripting in javascript for golang projects. This would be definitely enough, but in some way it may be a bit overkill - and scripts supporter shall need some knowledge of javascript which is not always straightforward :)
-
For JS in Go use goja, which offers excellent integration with Go. Also I maintain an extension that adds Common-JS compatibility to it.
-
For JS in Go use goja, which offers excellent integration with Go. Also I maintain an extension that adds Common-JS compatibility to it.
-
If you're curious how I set it up, check out blender/flamenco on Gitlab. The Goja/JS stuff is in internal/manager/job_compilers.
-
If you're interested, I have another project in which I use TypeScript (tsc) to compile to JavaScript/Common-JS that is compatible with goja. It works really well.
-
InfluxDB
Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
-
or perhaps use one of this list (depending on who's writing the configuration): https://github.com/dbohdan/embedded-scripting-languages
-
If performance is your main concern, there's Wasmer-go, but if you'd rather avoid CGO dependencies, there's wazero.
-
If performance is your main concern, there's Wasmer-go, but if you'd rather avoid CGO dependencies, there's wazero.
-
Pretty surprised no one has suggested starlark - Very nice ergonomics on both the scripting side and the interpreter. Worth a look! Especially nice when combined with starlight
-
You could also embed a Go interpreter, and have your scripts or expressions in Go. See for example https://github.com/traefik/yaegi. Disclaimer: I'm the author of this project.
-
You should take a look at Grule https://github.com/hyperjumptech/grule-rule-engine