From 0980fb19383409262e059ebb8048efc39a8ed417 Mon Sep 17 00:00:00 2001 From: George Adams Date: Wed, 11 Mar 2026 17:58:37 +0000 Subject: [PATCH] fix bug in JSON with custom URL --- __tests__/setup-go.test.ts | 4 ++++ dist/setup/index.js | 9 ++++++--- src/installer.ts | 14 +++++++++++--- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/__tests__/setup-go.test.ts b/__tests__/setup-go.test.ts index 47f31fb..5015e91 100644 --- a/__tests__/setup-go.test.ts +++ b/__tests__/setup-go.test.ts @@ -1136,6 +1136,10 @@ use . `Using custom Go download base URL: ${customBaseUrl}` ); expect(logSpy).toHaveBeenCalledWith('Install from custom download URL'); + // Version listing should use custom base URL, not go.dev + expect(getSpy).toHaveBeenCalledWith( + `${customBaseUrl}/?mode=json&include=all` + ); expect(dlSpy).toHaveBeenCalled(); expect(extractTarSpy).toHaveBeenCalled(); expect(cnSpy).toHaveBeenCalledWith(`::add-path::${expPath}${osm.EOL}`); diff --git a/dist/setup/index.js b/dist/setup/index.js index b85fd2d..796803e 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -77383,7 +77383,10 @@ function getInfoFromManifest(versionSpec_1, stable_1, auth_1) { } function getInfoFromDist(versionSpec, arch, goDownloadBaseUrl) { return __awaiter(this, void 0, void 0, function* () { - const version = yield findMatch(versionSpec, arch); + const dlUrl = goDownloadBaseUrl + ? `${goDownloadBaseUrl}/?mode=json&include=all` + : GOLANG_DOWNLOAD_URL; + const version = yield findMatch(versionSpec, arch, dlUrl); if (!version) { return null; } @@ -77421,12 +77424,12 @@ function getInfoFromDirectDownload(versionSpec, arch, goDownloadBaseUrl) { }; } function findMatch(versionSpec_1) { - return __awaiter(this, arguments, void 0, function* (versionSpec, arch = os_1.default.arch()) { + return __awaiter(this, arguments, void 0, function* (versionSpec, arch = os_1.default.arch(), dlUrl = GOLANG_DOWNLOAD_URL) { const archFilter = sys.getArch(arch); const platFilter = sys.getPlatform(); let result; let match; - const candidates = yield module.exports.getVersionsDist(GOLANG_DOWNLOAD_URL); + const candidates = yield module.exports.getVersionsDist(dlUrl); if (!candidates) { throw new Error(`golang download url did not return results`); } diff --git a/src/installer.ts b/src/installer.ts index c1bab49..e845e31 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -502,7 +502,14 @@ async function getInfoFromDist( arch: Architecture, goDownloadBaseUrl?: string ): Promise { - const version: IGoVersion | undefined = await findMatch(versionSpec, arch); + const dlUrl = goDownloadBaseUrl + ? `${goDownloadBaseUrl}/?mode=json&include=all` + : GOLANG_DOWNLOAD_URL; + const version: IGoVersion | undefined = await findMatch( + versionSpec, + arch, + dlUrl + ); if (!version) { return null; } @@ -553,7 +560,8 @@ export function getInfoFromDirectDownload( export async function findMatch( versionSpec: string, - arch: Architecture = os.arch() as Architecture + arch: Architecture = os.arch() as Architecture, + dlUrl: string = GOLANG_DOWNLOAD_URL ): Promise { const archFilter = sys.getArch(arch); const platFilter = sys.getPlatform(); @@ -562,7 +570,7 @@ export async function findMatch( let match: IGoVersion | undefined; const candidates: IGoVersion[] | null = await module.exports.getVersionsDist( - GOLANG_DOWNLOAD_URL + dlUrl ); if (!candidates) { throw new Error(`golang download url did not return results`);