Go Runtime
Go runtime requirements, setup, and gotchas for poly-bench
This guide walks through using Go with poly-bench, from init through run. It covers what gets created, how dependencies work, and common gotchas.
You need Go installed and available on your PATH. The table below summarizes the requirements.
| Requirement | Details |
|---|---|
| Binary | go on PATH |
| Version | Go 1.21+ |
| Verify | go version |
Install from go.dev/dl. If Go is missing when you run init, poly-bench can offer to install it interactively during poly-bench init.
When you run poly-bench init --languages go (or select Go in the interactive flow), poly-bench creates a Go module under .polybench/runtime-env/go/:
1.polybench/runtime-env/go/2└── go.modThe go.mod file uses your project name as the module path and defaults to Go 1.21. If you need a different Go version, you can override it in the project manifest:
1[project]2name = "my-bench"3
4[go]5version = "1.22"To add Go dependencies to your poly-bench project, use the add command with the --go flag:
$poly-bench add --go github.com/example/pkg@v1.2.3The spec format is module/...@version — for example, github.com/example/pkg@v1.2.3. Dependencies are stored in the poly-bench manifest and written to go.mod. poly-bench uses go get module/...@version internally to fetch transitive dependencies into go.sum. Using plain module@version (without the ...) can cause "missing go.sum entry" errors, so stick to the recommended format.
Running poly-bench install (or poly-bench build) invokes go get to resolve and download dependencies. The Go runtime does not need a separate install step beyond what the add command triggers; the build step simply ensures the module is ready for codegen.
When you run poly-bench run, poly-bench generates Go code and compiles it. The generated binary is built from the .polybench/runtime-env/go/ directory.
Execution differs by platform. On Linux, poly-bench uses plugin-based execution: it loads the compiled Go code as a shared library into the poly-bench process. On macOS and Windows, it uses subprocess execution instead, spawning the compiled binary as a separate process. This difference matters for debugging and profiling — on non-Linux platforms you will see a separate process in your process list.
module/...@version form to fetch transitive dependencies into go.sum. Using plain module@version can cause "missing go.sum entry" errors.GOBIN=<go_env>/bin go install golang.org/x/tools/gopls@latest.go 1.21 unless you override it in the polybench.toml manifest.