From fe60385a9418096af6fe0e20a43016114d8a1626 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arne=20J=C3=B8rgensen?= Date: Tue, 13 Oct 2026 08:01:35 +0200 Subject: [PATCH] Add support for beta versions in go.mod toolchain directive --- __tests__/setup-go.test.ts | 2 +- dist/setup/index.js | 2 +- src/installer.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/__tests__/setup-go.test.ts b/__tests__/setup-go.test.ts index fc0c38e..09d76c0 100644 --- a/__tests__/setup-go.test.ts +++ b/__tests__/setup-go.test.ts @@ -1237,7 +1237,7 @@ use . }); describe('go-version-file-toolchain', () => { - const goVersions = ['1.22.0', '1.21rc2', '1.18']; + const goVersions = ['1.22.0', '1.21rc2', '1.18', '1.18beta2']; const placeholderVersion = '1.19'; const buildGoMod = ( goVersion: string, diff --git a/dist/setup/index.js b/dist/setup/index.js index 2fec247..6782368 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -42367,7 +42367,7 @@ function parseGoVersionFile(versionFilePath) { // 'GOTOOLCHAIN' has been explicitly set if (process.env[GOTOOLCHAIN_ENV_VAR] !== GOTOOLCHAIN_LOCAL_VAL) { // toolchain directive: https://go.dev/ref/mod#go-mod-file-toolchain - const matchToolchain = contents.match(/^toolchain go(1\.\d+(?:\.\d+|rc\d+)?)/m); + const matchToolchain = contents.match(/^toolchain go(1\.\d+(?:\.\d+|(beta|rc)\d+)?)/m); if (matchToolchain) { return matchToolchain[1]; } diff --git a/src/installer.ts b/src/installer.ts index 1710a0e..f9c11f9 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -657,7 +657,7 @@ export function parseGoVersionFile(versionFilePath: string): string { if (process.env[GOTOOLCHAIN_ENV_VAR] !== GOTOOLCHAIN_LOCAL_VAL) { // toolchain directive: https://go.dev/ref/mod#go-mod-file-toolchain const matchToolchain = contents.match( - /^toolchain go(1\.\d+(?:\.\d+|rc\d+)?)/m + /^toolchain go(1\.\d+(?:\.\d+|(beta|rc)\d+)?)/m ); if (matchToolchain) { return matchToolchain[1];