Skip to content

Commit 992bd4e

Browse files
am-steadlucascosti
andauthored
[2023-03-30]: Setup-go Action now enabled with caching by default - [GA] github#9131 (github#35001)
Co-authored-by: Lucas Costi <[email protected]>
1 parent d966f6c commit 992bd4e

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

content/actions/automating-builds-and-tests/building-and-testing-go.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,21 @@ You can use `go get` to install dependencies:
128128

129129
### Caching dependencies
130130

131-
You can cache and restore the dependencies using the [`setup-go` action](https://github.com/actions/setup-go). By default, caching is disabled, but you can set the `cache` parameter to `true` to enable it.
131+
You can cache and restore dependencies using the [`setup-go` action](https://github.com/actions/setup-go). By default, caching is {% ifversion actions-setup-go-default-cache-enabled %}enabled when using the `setup-go` action.{% else %}disabled, but you can set the `cache` parameter to `true` to enable it.{% endif %}
132+
133+
{% ifversion actions-setup-go-default-cache-enabled %}
134+
The `setup-go` action searches for the dependency file, `go.sum`, in the repository root and uses the hash of the dependency file as a part of the cache key.
135+
136+
You can use the `cache-dependency-path` parameter for cases when multiple dependency files are used, or when they are located in different subdirectories.
137+
138+
```yaml{:copy}
139+
- name: Setup Go
140+
- uses: {% data reusables.actions.action-setup-go %}
141+
with:
142+
go-version: '1.17'
143+
cache-dependency-path: subdir/go.sum
144+
```
145+
{% else %}
132146

133147
When caching is enabled, the `setup-go` action searches for the dependency file, `go.sum`, in the repository root and uses the hash of the dependency file as a part of the cache key.
134148

@@ -149,6 +163,7 @@ Alternatively, you can use the `cache-dependency-path` parameter for cases when
149163
cache: true
150164
cache-dependency-path: subdir/go.sum
151165
```
166+
{% endif %}
152167

153168
If you have a custom requirement or need finer controls for caching, you can use the [`cache` action](https://github.com/marketplace/actions/cache). For more information, see "[AUTOTITLE](/actions/using-workflows/caching-dependencies-to-speed-up-workflows)."
154169

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Reference: #9131
2+
# Setup-Go Action now enabled with caching by default
3+
versions:
4+
fpt: '*'
5+
ghec: '*'
6+
ghes: '>=3.9'
7+
ghae: '>=3.9'
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
actions/setup-go@{% ifversion actions-node16-action %}v3{% else %}v2{% endif %}
1+
actions/setup-go@{% ifversion actions-setup-go-default-cache-enabled %}v4{% elsif actions-node16-action %}v3{% else %}v2{% endif %}

0 commit comments

Comments
 (0)