mirror of
https://github.com/actions/setup-go.git
synced 2025-09-06 10:16:02 -06:00
Prefer installing version from toolchain
directive
Prefer this over the version from the `go` directive. Per the docs[1] > The toolchain line declares a suggested toolchain to use with the module or workspace It seems reasonable to use this, since running this action in a directory containing a `go.mod` (or `go.work`) suggests the user is wishing to work _with the module or workspace_. Link: https://go.dev/doc/toolchain#config [1] Issue: https://github.com/actions/setup-go/issues/457
This commit is contained in:
parent
613315d242
commit
7252af563b
4 changed files with 75 additions and 6 deletions
|
@ -495,8 +495,15 @@ export function parseGoVersionFile(versionFilePath: string): string {
|
|||
path.basename(versionFilePath) === 'go.mod' ||
|
||||
path.basename(versionFilePath) === 'go.work'
|
||||
) {
|
||||
const match = contents.match(/^go (\d+(\.\d+)*)/m);
|
||||
return match ? match[1] : '';
|
||||
// toolchain directive: https://go.dev/ref/mod#go-mod-file-toolchain
|
||||
const matchToolchain = contents.match(/^toolchain go(\d+(\.\d+)*)/m);
|
||||
if (matchToolchain) {
|
||||
return matchToolchain[1];
|
||||
}
|
||||
|
||||
// go directive: https://go.dev/ref/mod#go-mod-file-go
|
||||
const matchGo = contents.match(/^go (\d+(\.\d+)*)/m);
|
||||
return matchGo ? matchGo[1] : '';
|
||||
}
|
||||
|
||||
return contents.trim();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue