github.com/boxlite-ai/boxlite/sdks/go to run a command in an isolated microVM sandbox within minutes, without managing virtual machines, images, or networking yourself. Go has no SimpleBox-style one-line wrapper — you build the runtime and the box explicitly, in two calls.
Prerequisites
- A machine with hardware virtualization — see Installation for the supported platforms.
- Go 1.24 or newer, with CGO enabled (the default).
cmd/setup detects your platform and SDK version and downloads libboxlite.a plus boxlite.h from GitHub Releases straight into your Go module cache, so a later go build links against it with no separate install step. It prints Setup complete. when done; if the download stalls, see Troubleshooting.
Quick Example
Write the following intomain.go, then run go build && ./<binary>.
v0.9.7 module (go get + cmd/setup, no local build):
Parameters and Returns (Core API)
boxlite.NewRuntime / *Runtime (runtime handle)
*Box (box handle)
A failed start returns(nil, err). Readingres.ExitCodebefore checkingerron a failedExeccall is a nil-pointer dereference, not a graceful zero value.
*Cmd (built via Command)
This differs from the standard library.os/exec’sCmd.Run/Outputreturn a*exec.ExitErroron a non-zero exit. BoxLite’sCmddoes not —Run/Outputreturnniland you readExitCode()yourself, exactly likeBox.Exec.
ExecResult
Functional options (BoxOption, passed to Create / GetOrCreate)
Verified on this machine: with no options set, a fresh box reports
nproc = 1 (default 1 vCPU) and its guest kernel is Linux 6.12.76.
Troubleshooting
Setup download times out
cmd/setup downloads a large (~100+ MB) archive under a fixed timeout. On a slow connection this can fail partway through — reproduced on this machine after successfully extracting libboxlite.a but before reaching boxlite.h. Re-run go run github.com/boxlite-ai/boxlite/sdks/go/cmd/setup; it detects the already-extracted files and resumes from there. It succeeded on the fourth attempt in this environment.
A failed Exec panics with a nil-pointer dereference
(nil, err) from Exec, not a res with a nonzero ExitCode. Always check err before reading res:
A non-zero exit code was not reported as an error
Exec, Cmd.Run, and Cmd.Output all return nil for err when the command itself ran and simply exited non-zero — check ExitCode yourself:
Distinguishing error types
Errors are*boxlite.Error with a .Code, checkable with the typed helpers:
IsNotFound / IsAlreadyExists / IsInvalidState / IsStopped cover the common cases.
Build error: -tags boxlite_dev behavior
If you are building this repository from source rather than consuming the published module, go build alone links against a prebuilt library (the one cmd/setup downloaded). Building against your own locally-compiled core instead requires make dev:go (from the repository root) followed by go build -tags boxlite_dev ./... — see Building from source.
Startup failure: no hardware virtualization (environment constraint)
- Linux: confirm
/dev/kvmexists and the current user is in thekvmgroup. - macOS (Apple Silicon): uses Hypervisor.framework and does not need
/dev/kvm. - WSL2: enable nested virtualization and install KVM.
Create/Exec, not a crash — check it like any other returned error.
Next Steps
- Run any language or command inside the box: replace the
"echo", "Hello from BoxLite!"arguments with your own, and"alpine:latest"with the image you need. - For streaming output or stdin, use
Box.Command(...)(mirrorsos/exec) orBox.StartExecutionfor the lowest-levelWrite/Wait/Kill/Signalaccess. - Other languages: see the Python quickstart, the Node.js quickstart, and the Rust quickstart.

