Skip to content
Latchkey

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

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →