Go
Provides Go language support for heph. The go provider analyzes Go packages
and generates targets for building libraries, binaries, and tests. It reads
package metadata, resolves source files and module dependencies, and wires up
the targets needed to compile and run Go code. Managed drivers do the
underlying work: toolchain provisioning (go_toolchain), package metadata
analysis (go_golist), Go package compilation (go_compile), test main
generation (go_testmain), and per-package lint/format analysis (go_lint,
go_lint_gate, go_lint_fix, go_format, go_format_check).
Driver
A driver is the execution backend that knows how to run a particular kind of
target. This plugin registers nine drivers: go_toolchain, go_golist,
go_compile, go_testmain, go_lint, go_lint_gate, go_lint_fix,
go_format, and go_format_check. These are internal — you should not
interact with them directly.
Enabling it
The Go plugin is an external plugin — it is not compiled into the heph
binary. It ships as a shared library (cdylib) with a manifest file
(heph-go-plugin.json). A single plugins: entry loads the provider and all
four drivers at once.
Use url: to have heph fetch and cache the plugin automatically:
plugins:
- url: https://github.com/hephbuild/heph-artifacts-v1/releases/latest/download/heph-go-plugin.json
checksum: sha256:<hex> # optional; pin from heph-go-plugin.json.sha256
The checksum field is optional but recommended — it pins the manifest to a
known digest so a tampered or misdelivered manifest is rejected before loading.
See Pinning manifests with checksums
for details.
Configuration
plugins:
- url: https://github.com/hephbuild/heph-artifacts-v1/releases/latest/download/heph-go-plugin.json
checksum: sha256:<hex> # optional
options:
gotool: "1.27.0" # required — pinned version, "host", or a target address
skip: [] # optional
checksums: # optional; recommended for supply-chain verification
"1.27.0/linux/amd64": "<sha256hex>"
"1.27.0/darwin/arm64": "<sha256hex>"
Options
| Option | Type | Default | Description |
|---|---|---|---|
gotool | string | required | Go toolchain to use. Set to a pinned version like "1.27.0" to download the SDK hermetically from go.dev/dl, "host" to use the go binary already on the host's PATH, or a target address like "//@heph/bin:go" to use the toolchain a target produces. |
govet | string (target address) | the plugin's own published heph-govet build | The heph-govet binary that lint and format targets run. See Pinning the analyzer binary. |
cctool | string (target address) | the host's cc, via hostbin (//@heph/bin:cc) | The C compiler a race-detector build stages where it needs cgo. Only resolved when such a build actually runs. |
runner | string (target address) | unset | Exec runner every Go tool (go list, go tool compile/asm/pack, gofmt, heph-govet) runs under, or "local". Reaches the go_* drivers as their default and this provider's own bash targets (the standard library install, the third-party module download) as their runner field. See Running Go tools under a runner. |
checksums | map[string, string] | {} | Expected SHA-256 digests for hermetic SDK tarballs, keyed "<version>/<goos>/<goarch>" (e.g. "1.27.0/linux/amd64"), and for govet release downloads, keyed "govet/<tag>/<goos>/<goarch>". Look up SDK values at go.dev/dl/?mode=json. When a key is missing the download is unverified (a warning is logged). SDK checksums have no effect when gotool = "host". |
skip | string[] | [] | Workspace-relative glob patterns for directories to exclude from Go package discovery. |
walk_db | path | <homeDir>/heph-plugin-go-fswalk.db | Path to the filesystem walk cache database. |