@@ -17,10 +17,10 @@ jobs:
17
17
os : [ubuntu-latest, macos-latest, windows-latest]
18
18
runs-on : ${{ matrix.os }}
19
19
steps :
20
- - uses : actions/setup-go@v3
20
+ - uses : actions/checkout@v3
21
+ - uses : actions/setup-go@v4
21
22
with :
22
23
go-version : ${{ matrix.go-version }}
23
- - uses : actions/checkout@v3
24
24
- run : go test ./...
25
25
` ` `
26
26
@@ -69,8 +69,10 @@ Note that these take effect for future steps in the job.
69
69
70
70
# ### How do I set up caching between builds?
71
71
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` :
74
76
75
77
` ` ` yaml
76
78
- uses: actions/cache@v3
@@ -81,28 +83,6 @@ downloaded modules:
81
83
${{ runner.os }}-go-
82
84
` ` `
83
85
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
- ~\A ppData\L ocal\g o-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
-
106
86
See [this guide](https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows)
107
87
for more details.
108
88
0 commit comments