Update module cache to use go.mod as key

This commit is contained in:
Priyagupta108 2026-01-12 14:42:22 +05:30
parent ae252ee6fb
commit 6e29faab03
9 changed files with 73 additions and 68 deletions

View file

@ -43,6 +43,8 @@ toolchain go1.23.2 // V6 uses this exact version
**Intelligent Caching**
Cache keys now incorporate the `toolchain` directive version from `go.mod`, eliminating cache conflicts when switching between different toolchain versions within the same Go minor release.
By default, caching for Go modules now relies on `go.mod`. To use `go.sum`, configure the `cache-dependency-path` input.
For more details, see the [full release notes](https://github.com/actions/setup-go/releases/tag/v6.0.0).
### V5 Changes
@ -257,7 +259,7 @@ The action features integrated caching for Go modules and build outputs. Built o
#### Automatic Caching
Default behavior: Searches for `go.sum` in the repository root and uses its hash for the cache key.
Default behavior: Searches for `go.mod` in the repository root and uses its hash for the cache key.
```yaml
steps:
@ -368,7 +370,7 @@ jobs:
path: |
${{ env.GO_MOD_CACHE }}
${{ env.GO_BUILD_CACHE }}
key: setup-go-${{ runner.os }}-${{ env.ARCH }}-${{ env.CACHE_OS_SUFFIX }}go-${{ steps.setup-go.outputs.go-version }}-${{ hashFiles('**/go.sum') }}
key: setup-go-${{ runner.os }}-${{ env.ARCH }}-${{ env.CACHE_OS_SUFFIX }}go-${{ steps.setup-go.outputs.go-version }}-${{ hashFiles('**/go.mod') }}
- name: Download modules
run: go mod download
- name: Build