This commit is contained in:
Matthew Hughes 2025-06-11 16:19:44 -05:00 committed by GitHub
commit 2d6e7e6f32
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 118 additions and 9 deletions

View file

@ -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();