actions/setup-go: Install Go in CI
setup-go installs Go and caches modules and build output automatically.
Pin a Go version or read it from go.mod. setup-go caches the module and build cache by default for faster repeat runs.
Key inputs (with:)
- go-version: e.g. 1.22 or 1.22.x.
- go-version-file: read the version from go.mod or go.work.
- cache: true by default; caches modules and build cache.
- cache-dependency-path: path to go.sum for the cache key.
- check-latest: fetch the latest patch matching the constraint.
Example workflow
.github/workflows/ci.yml
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- run: go test ./...On any runner
setup-go runs on any runner. Latchkey managed runners run it unchanged, cheaper and self-healing.
Key takeaways
- go-version-file keeps CI aligned with go.mod.
- Module and build caching is on by default.
- check-latest pulls newer patch releases when you want them.
Related guides
actions/checkout: Inputs & Workflow UsageReference for actions/checkout: clone your repository into the runner, control fetch-depth, submodules, refs,…
codecov/codecov-action: Upload Coverage ReportsReference for codecov/codecov-action: upload test coverage reports to Codecov with a token, flags, and file p…