Skip to main content
Every signature below is verified against the built module (go get github.com/boxlite-ai/boxlite/sdks/[email protected] + go run .../cmd/setup, then go build) and, where marked, against a real run’s output.

Prerequisites

  • Go 1.24+ with CGO enabled (the default) — see Go quickstart for the full install flow (go get + cmd/setup).

Core types and methods

*Runtime

*Box

A failed Exec/StartExecution returns (nil, err). Check err before touching the result — a nil-pointer dereference on the result is a real, reproduced panic if you skip this.

*Cmd (from Box.Command)

Differs from os/exec. The standard library’s Cmd.Run/Output return a *exec.ExitError on a non-zero exit. BoxLite’s Cmd returns nil in that case — read ExitCode() yourself, matching Box.Exec’s own non-throwing behavior.

ExecResult (from Exec)

*Execution (from StartExecution) / ExecutionOptions

Functional options (BoxOption)

BoxInfo

RuntimeMetrics / BoxMetrics

Error handling

Errors are *boxlite.Error, with .Code an ErrorCode and .Message a string; Error() string formats both. Typed helpers: IsNotFound(err) / IsAlreadyExists(err) / IsInvalidState(err) / IsStopped(err). Verified: a start failure (missing binary) produced
— code=1 is ErrInternal, not ErrExecution; do not assume a spawn failure is always ErrExecution.

Troubleshooting

Nil-pointer dereference after a failed Exec

See the Go quickstart — a start failure returns (nil, err); check err first.

Cmd.Run/Output return nil on a non-zero exit

This is intentional and matches Box.Exec, but it is the opposite of os/exec’s behavior — see the Go quickstart.

ld: warning: ignoring duplicate libraries: '-lresolv'

A harmless link-time warning on macOS, reproduced on every build against this SDK; not an error.

context deadline exceeded from cmd/setup

The one-time native-library download can exceed the tool’s internal timeout on a slow connection. Re-running it resumes from whatever was already extracted — see the Go quickstart.

Next steps

  • Go quickstart for the full install flow and a runnable first program.
  • Box types and Manage sandboxes for the capabilities every SDK shares, expressed here as BoxOption functional options instead of keyword arguments.

Go-specific troubleshooting

Carried over from the per-language quickstart, which is now one page for all languages.

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

A start failure (for example, a missing binary) returns (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: