Set up the Go cache
Go 1.24 and later can hand their build cache to a helper through GOCACHEPROG. The Snowstead helper reuses compiler output from compatible builds. Go still runs the build on your machine.
Create a cache in the dashboard and enable Go. A cache can hold Nix, Go, or both, with the same visibility and tokens.
A machine that reads downloads what the cache already holds and uploads nothing. A machine that reads and writes also uploads what it builds, so other machines skip that work and use what it uploaded. Writing always needs a token that can write. You choose which machines get one.
1. Build the helper
Install Go 1.24 or later, then build the helper on each machine, including CI. The helper currently ships from the go-remote-cache branch, not a published module version. Build it before enabling GOCACHEPROG;
the command below explicitly disables any existing helper for this build.
git clone --branch go-remote-cache https://github.com/Polymath-AS/snowstead.git mkdir -p "$HOME/.local/bin" env -u GOCACHEPROG go -C snowstead/apps/go-cache build -o "$HOME/.local/bin/snowstead-go-cache" . export GOCACHEPROG="$HOME/.local/bin/snowstead-go-cache"
Use an absolute path for GOCACHEPROG. The helper has no subcommands; Go starts it automatically.
2. Point Go at your cache
Create a token under Tokens in the dashboard that reads this cache, and store it as SNOWSTEAD_TOKEN. Read-only mode stops uploads, whatever the token allows.
Put these lines in your shell profile or the project's .envrc. This example uses organization acme and cache main. Replace them with your own slugs. The Go address is your cache's address followed by /go: https://<org-slug>.snowstead.com/<cache-name>/go. The helper adds /v1/actions/<id>; don't add it yourself.
export GOCACHEPROG="$HOME/.local/bin/snowstead-go-cache" export SNOWSTEAD_GO_CACHE_URL=https://acme.snowstead.com/main/go export SNOWSTEAD_GO_CACHE_TOKEN="$SNOWSTEAD_TOKEN" export SNOWSTEAD_GO_CACHE_READ_ONLY=true go build -trimpath ./... go test -trimpath ./...
3. Use it in CI
Store the token as the SNOWSTEAD_TOKEN repository secret. GitHub gives workflows from fork pull requests no secrets, so those runs
have no token and can't read a private cache.
This workflow uses Go 1.24.5 as an example. Use the same Go version on laptops and in CI.
on:
push:
branches: [main]
pull_request:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.24.5"
cache: false
- name: Build the cache helper
run: |
git clone --branch go-remote-cache https://github.com/Polymath-AS/snowstead.git "$RUNNER_TEMP/snowstead-helper"
env -u GOCACHEPROG go -C "$RUNNER_TEMP/snowstead-helper/apps/go-cache" build -o "$RUNNER_TEMP/snowstead-go-cache" .
- name: Build with the cache
env:
SNOWSTEAD_GO_CACHE_URL: https://acme.snowstead.com/main/go
SNOWSTEAD_GO_CACHE_TOKEN: ${{ secrets.SNOWSTEAD_TOKEN }}
SNOWSTEAD_GO_CACHE_READ_ONLY: "true"
run: |
export GOCACHEPROG="$RUNNER_TEMP/snowstead-go-cache"
go build -trimpath ./...
go test -trimpath ./... What makes a hit
Machines share only what they build the same way. Go decides which outputs are reusable; Snowstead doesn't change your compiler settings.
- The same OS and CPU. A Mac's builds never match Linux CI's, so Macs share with each other and Linux machines with each other.
- The same Go version,
GOOSandGOARCH, and build flags. -trimpatheverywhere, so output doesn't depend on where the code is checked out.
Whatever a build outputs is uploaded. Keys are hashes, so environment variables and tokens aren't sent, but a
secret compiled into the output, such as one set with -ldflags -X, is stored like any other output.
Keep secrets out of builds, and keep the cache private when in doubt.
4. Check that it works
The helper prints a summary to stderr when Go finishes. Build once on one machine, then build the same code with a
matching toolchain and flags on another machine with a cold local cache. Look for remote_hits.
Repeated builds on the same machine may use local_hits instead.
snowstead-go-cache: local_hits=0 remote_hits=3510 misses=1 uploads=0 upload_errors=0 conflicts=0 downloaded_bytes=1487279053 uploaded_bytes=0
remote_hits=0: the local cache may already have the output. Otherwise, check the URL, read permission, and whether the first build used matching build inputs. See What makes a hit.uploads=0on a writer: check read-only mode, write permission, and whether the output is already cached. Look atupload_errorsfor failed uploads.conflictsabove zero: different output was offered for an existing action. The first upload stays; investigate mismatched or non-reproducible builds.
Cache misses and remote failures fall back to local compilation. This doesn't make build failures impossible: your code, toolchain, and local disk still need to work.
Retention and local disk use
Remote Go entries have a 64 MiB limit and expire seven days after their first upload. Reading an entry doesn't extend its lifetime. Go storage and retention are separate from Nix paths.
The helper also stores output locally, with no automatic eviction. Set SNOWSTEAD_GO_CACHE_DIR to
choose its directory, monitor disk use, and clean it up when no build is using it. Clearing remote Go entries does
not remove copies already held on other machines.
For Nix setup, see Getting started.