Go SDK
RBS provides hermetic Go support with automatic Go SDK management, hermetic builds withGOPROXY=off, and cross-compilation via platform flags.
Setup
Toolchain
Register a Go toolchain inWORKSPACE.rbs:
Rules
go_library
Creates a reusable Go library (source packaging for dependents).
| Attribute | Type | Description |
|---|---|---|
name | string | Unique target name (required). |
srcs | list | Go source files (can include go.mod, go.sum, vendor files). |
deps | list | Local go_library dependencies. |
cgo | bool | Enable CGO (default False). |
go_binary
Creates an executable Go binary.
| Attribute | Type | Description |
|---|---|---|
name | string | Unique target name (required). |
srcs | list | Go source files (required). |
deps | list | Local go_library dependencies. |
goflags | list | Extra flags passed to go build (e.g., -ldflags). |
cgo | bool | Enable CGO (default False). |
go_test
Runs Go tests.
Hermetic Builds
By default, RBS runs Go builds withGOPROXY=off and GOSUMDB=off, ensuring the Go tool cannot fetch modules from the network at build time. All dependencies must be vendored or pre-fetched.
For stdlib-only builds (no go.mod), RBS automatically sets GO111MODULE=off so go build works without a module root.
Cross-Compilation
Use theRBS_TARGET_PLATFORM environment variable to cross-compile: