yaegi
ghcr.io/openotters/tools/yaegi:latestEmbedded Go interpreter. Pass Go source via stdin (with args=['run','-']); supports stdlib only, no module fetches, no cgo.
Usage
Usage
Run Go source under the embedded yaegi interpreter (a pure-Go implementation of the Go language, v0.16.1). Stdlib only โ no cgo, no module fetches. Each invocation runs in a fresh interpreter; nothing persists between calls.
Primary form โ full program via stdin
Pass args: ["run"] and send a complete package main program on
stdin. This is the cleanest form: only your program's output is
returned.
{ "args": ["run"], "stdin": "package main\nimport "fmt"\nfunc main(){ fmt.Println("hi") }" }
Quick one-liner โ -e
Pass args: ["-e", "<statements>"] to evaluate statements in an
implicit main. fmt is preloaded; additional import statements
are NOT permitted in this mode.
{ "args": ["-e", "for i:=0;i<3;i++ { fmt.Println(i) }"] }
Other subcommands
yaegi version โ prints "0.16.1" yaegi help [cmd] โ usage info yaegi test [path] โ run test funcs in a package yaegi extract pkgs... โ generate wrapper file for a package
Pitfalls
- Stdin with NO args drops into a REPL-style mode that echoes
expression values and a trailing pointer. Always pass
["run"]when sending a full program on stdin. run -e <src>also leaks a trailing pointer to stdout. Use plain-efor snippets, orrun+ stdin for full programs.- In
-emode, put each statement on its own line; semicolons inside one-estring can confuse the parser around imports.
Tags
4 tags- latest
- v0.16.1
- v0.16
- v0