docs: document automatic go.mod detection

This commit is contained in:
raeperd 2025-10-12 17:56:24 +09:00
parent ec93c40362
commit a16a57d83d
2 changed files with 16 additions and 2 deletions

View File

@ -187,11 +187,25 @@ from thils file will be:
The version can specify a patch version or omit it altogether (e.g., `go 1.22.0` or `go 1.22`). The version can specify a patch version or omit it altogether (e.g., `go 1.22.0` or `go 1.22`).
If a patch version is specified, that specific patch version will be used. If a patch version is specified, that specific patch version will be used.
If no patch version is specified, it will search for the latest available patch version in the cache, If no patch version is specified, it will search for the latest available patch version in the cache,
[versions-manifest.json](https://github.com/actions/go-versions/blob/main/versions-manifest.json), and the [versions-manifest.json](https://github.com/actions/go-versions/blob/main/versions-manifest.json), and the
[official Go language website](https://golang.org/dl/?mode=json&include=all), in that order. [official Go language website](https://golang.org/dl/?mode=json&include=all), in that order.
### Automatic go.mod detection
**New in v6**: If neither `go-version` nor `go-version-file` is specified, the action will automatically look for a `go.mod` file in the repository root and use the Go version specified in it. This simplifies workflows for projects that already have a `go.mod` file.
```yaml
steps:
- uses: actions/checkout@v5
- uses: actions/setup-go@v6
# Automatically uses go.mod from repository root
- run: go version
```
### Specifying a custom path
If both the `go-version` and the `go-version-file` inputs are provided then the `go-version` input is used. If both the `go-version` and the `go-version-file` inputs are provided then the `go-version` input is used.
> The action will search for the `go.mod` file relative to the repository root > The action will search for the `go.mod` file relative to the repository root

View File

@ -5,7 +5,7 @@ inputs:
go-version: go-version:
description: 'The Go version to download (if necessary) and use. Supports semver spec and ranges. Be sure to enclose this option in single quotation marks.' description: 'The Go version to download (if necessary) and use. Supports semver spec and ranges. Be sure to enclose this option in single quotation marks.'
go-version-file: go-version-file:
description: 'Path to the go.mod or go.work file.' description: 'Path to the go.mod or go.work file. If not specified, the action will automatically use go.mod from the workspace root if it exists.'
check-latest: check-latest:
description: 'Set this option to true if you want the action to always check for the latest available version that satisfies the version spec' description: 'Set this option to true if you want the action to always check for the latest available version that satisfies the version spec'
default: false default: false