From 5a5cdc8151239e38aa97416025497a8c1460f31f Mon Sep 17 00:00:00 2001 From: Dmitry Shibanov Date: Thu, 8 Dec 2022 22:10:41 +0100 Subject: [PATCH] minor fix --- dist/setup/index.js | 8 +++++++- src/installer.ts | 14 ++++++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/dist/setup/index.js b/dist/setup/index.js index a494179..806c1b1 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -63236,6 +63236,8 @@ function getGo(versionSpec, checkLatest, auth, arch = os_1.default.arch()) { manifest = yield getManifest(auth); let stableVersion = yield resolveStableVersionInput(versionSpec, arch, osPlat, manifest); if (!stableVersion) { + let archFilter = sys.getArch(arch); + let platFilter = sys.getPlatform(); const dlUrl = 'https://golang.org/dl/?mode=json&include=all'; let candidates = yield module.exports.getVersionsDist(dlUrl); if (!candidates) { @@ -63244,8 +63246,12 @@ function getGo(versionSpec, checkLatest, auth, arch = os_1.default.arch()) { const fixedCandidates = candidates.map(item => { return Object.assign(Object.assign({}, item), { version: makeSemver(item.version) }); }); - stableVersion = yield resolveStableVersionInput(versionSpec, arch, osPlat, fixedCandidates); + stableVersion = yield resolveStableVersionInput(versionSpec, archFilter, platFilter, fixedCandidates); + if (!stableVersion) { + throw new Error(`Unable to find Go version '${versionSpec}' for platform ${osPlat} and architecture ${arch}.`); + } } + versionSpec = stableVersion; } if (checkLatest) { core.info('Attempting to resolve the latest version from the manifest...'); diff --git a/src/installer.ts b/src/installer.ts index acea2ba..f6fda1c 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -52,6 +52,8 @@ export async function getGo( ); if (!stableVersion) { + let archFilter = sys.getArch(arch); + let platFilter = sys.getPlatform(); const dlUrl: string = 'https://golang.org/dl/?mode=json&include=all'; let candidates: | IGoVersion[] @@ -69,11 +71,19 @@ export async function getGo( stableVersion = await resolveStableVersionInput( versionSpec, - arch, - osPlat, + archFilter, + platFilter, fixedCandidates ); + + if (!stableVersion) { + throw new Error( + `Unable to find Go version '${versionSpec}' for platform ${osPlat} and architecture ${arch}.` + ); + } } + + versionSpec = stableVersion; } if (checkLatest) {