mirror of
https://github.com/actions/setup-go.git
synced 2025-06-18 23:02:59 -06:00
Merge 145e58d96c
into 4de67c04ab
This commit is contained in:
commit
2d6e7e6f32
4 changed files with 118 additions and 9 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