go-version: '1.22.0-rc.1' # The Go version to download (if necessary) and use
go-version: '1.24.0-rc.1' # The Go version to download (if necessary) and use
- run: go version
```
@ -126,7 +126,7 @@ steps:
- uses: actions/checkout@v5
- uses: actions/setup-go@v6
with:
go-version: '1.16.0-beta.1' # The Go version to download (if necessary) and use
go-version: '1.23.0-beta.1' # The Go version to download (if necessary) and use
- run: go version
```
@ -146,7 +146,7 @@ steps:
**Previous Stable Release**
If `oldstable` is provided, when current release is 1.19.x, action will resolve version as 1.18.x, where x is the latest patch release.
If `oldstable` is provided, when current release is 1.23.x, action will resolve version as 1.22.x, where x is the latest patch release.
```yaml
steps:
- uses: actions/checkout@v5
@ -199,7 +199,7 @@ steps:
- uses: actions/checkout@v5
- uses: actions/setup-go@v6
with:
go-version: '1.21'
go-version: '1.23'
check-latest: true # Always check for the latest patch release
- run: go version
```
@ -210,7 +210,7 @@ steps:
### Caching
Caching is enabled by default. The action automatically caches and restores Go modules and build outputs using toolkit/cache with minimal configuration.
The action has a built-in functionality for caching and restoring go modules and build outputs. It uses [toolkit/cache](https://github.com/actions/toolkit/tree/main/packages/cache) under the hood but requires less configuration settings. Caching is enabled by default. The action automatically caches and restores Go modules and build outputs using toolkit/cache with minimal configuration.
#### Automatic Caching
@ -221,7 +221,7 @@ steps:
- uses: actions/checkout@v5
- uses: actions/setup-go@v6
with:
go-version: '1.21'
go-version: '1.23'
# cache: true (default)
- run: go run hello.go
```
@ -240,7 +240,7 @@ steps:
- uses: actions/checkout@v5
- uses: actions/setup-go@v6
with:
go-version: '1.17'
go-version: '1.23'
check-latest: true
cache-dependency-path: |
subdir/go.sum
@ -254,7 +254,7 @@ steps:
- uses: actions/checkout@v5
- uses: actions/setup-go@v6
with:
go-version: '1.17'
go-version: '1.23'
cache-dependency-path: "**/*.sum"
- run: go run hello.go
```
@ -266,7 +266,7 @@ steps:
- uses: actions/checkout@v5
- uses: actions/setup-go@v6
with:
go-version: '1.21'
go-version: '1.23'
cache: false
- run: go run hello.go
```
@ -283,7 +283,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
go-version: ['1.20', '1.21', '1.22']
go-version: ['1.21', '1.22', '1.23']
steps:
- uses: actions/checkout@v5
- uses: actions/setup-go@v6
@ -298,11 +298,11 @@ jobs:
| Syntax Type | Example | Description |
|-------------|---------|-------------|
| Specific version | `1.21.5` | Exact version |
| Semantic range | `^1.21.0` | Compatible with 1.21.0 |
| Comparison operators | `>=1.20.0` | Version 1.20.0 or higher |