gengoscript — an embeddable scripting language for user-defined logic without ambient machine access.
Go-influenced syntax, explicit imports, and host-controlled capabilities.
gengoscript — an embeddable scripting language for user-defined logic without ambient machine access.
Go-influenced syntax, explicit imports, and host-controlled capabilities.
std := import("std")
type Quantity int range 1..999
type UnitPrice float range 0.01..9999.99
type Discount int range 0..100
type LineTotal float range 0.0..999999.99
subtype BulkDiscount Discount range 5..40
func line_total(qty Quantity, price UnitPrice, disc Discount) LineTotal {
q := float(qty)
p := float(price)
d := float(disc)
return LineTotal(q * p * (1.0 - d / 100.0))
}
total := line_total(
Quantity(12),
UnitPrice(49.95),
BulkDiscount(15),
)
std.io.printf("total: %.2f\n", float(total))
Gengoscript is a host-embedded language for running untrusted or user-supplied scripts under explicit host control. Scripts get language utilities through std, but filesystem, network, and host integration are available only if the embedding application grants them.
Each runtime instance is isolated and host-configured. The host decides which capability modules and host modules exist, whether script I/O is enabled, and what instruction, heap, stack, and frame limits apply to execution.
Filesystem, HTTP, and other system access are opt-in. Scripts can import only the capability and host modules the application exposes.
Domain rules live in the script itself. Range types, predicates, and subtypes let values fail at construction instead of later in host-side validation.
Embed from Zig through the runtime API or from other hosts through the C-compatible engine surface. Load a script once, call exported functions from your request loop, or drive the engine directly through calls such as engine_run and engine_call.
Instruction budgets, heap limits, stack limits, and per-instance isolation let hosts bound script cost and failure scope.
Install from the published artifacts on GitHub Releases, or build the CLI from source when you want the latest tree. Gengoscript requires Zig 0.16.0 for source builds.
Use the native CLI for local development and REPL work. Build the WASI target when you want the WebAssembly runtime described in the docs, or when you want to run the CLI through wasmtime.
# Build CLI from source
zig build -Dpreset=dev cli
# Build WASI runtime
zig build -Dpreset=dev wasi
# Execute
./zig-out/bin/gengo script.gengo
# Run the WASI build with wasmtime
wasmtime --dir . ./build/gengo-cli.wasm -- script.gengo
Installation is documented through published artifacts and explicit build steps, not remote shell bootstrap scripts.
Use the Gengoscript Playground for a quick feel, then read the docs for the language, embedding model, engine API, and security controls.