Skip to content

Commit 8a0a9dc

Browse files
committed
README: adapt to actions/setup-go@v4 caching
1 parent efdbb1f commit 8a0a9dc

File tree

1 file changed

+6
-26
lines changed

1 file changed

+6
-26
lines changed

README.md

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ jobs:
1717
os: [ubuntu-latest, macos-latest, windows-latest]
1818
runs-on: ${{ matrix.os }}
1919
steps:
20-
- uses: actions/setup-go@v3
20+
- uses: actions/checkout@v3
21+
- uses: actions/setup-go@v4
2122
with:
2223
go-version: ${{ matrix.go-version }}
23-
- uses: actions/checkout@v3
2424
- run: go test ./...
2525
```
2626
@@ -69,8 +69,10 @@ Note that these take effect for future steps in the job.
6969

7070
#### How do I set up caching between builds?
7171

72-
Use [actions/cache](https://github.com/actions/cache). For example, to cache
73-
downloaded modules:
72+
Since v4, [actions/setup-go](https://github.com/actions/setup-go) caches `GOCACHE`
73+
and `GOMODCACHE` automatically, using `go.sum` as the cache key.
74+
You can turn that off via `cache: false`, and then you may also use your own
75+
custom caching, for example to only keep `GOMODCACHE`:
7476

7577
```yaml
7678
- uses: actions/cache@v3
@@ -81,28 +83,6 @@ downloaded modules:
8183
${{ runner.os }}-go-
8284
```
8385

84-
You can also include Go's build cache, to improve incremental builds:
85-
86-
```yaml
87-
- uses: actions/cache@v3
88-
with:
89-
# In order:
90-
# * Module download cache
91-
# * Build cache (Linux)
92-
# * Build cache (Mac)
93-
# * Build cache (Windows)
94-
path: |
95-
~/go/pkg/mod
96-
~/.cache/go-build
97-
~/Library/Caches/go-build
98-
~\AppData\Local\go-build
99-
key: ${{ runner.os }}-go-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }}
100-
restore-keys: |
101-
${{ runner.os }}-go-${{ matrix.go-version }}-
102-
```
103-
104-
This is demonstrated via the `test-cache` job [in this very repository](https://github.com/mvdan/github-actions-golang/actions).
105-
10686
See [this guide](https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows)
10787
for more details.
10888

0 commit comments

Comments
 (0)