From f1f69d49da7f85ae8f8d0d039e7478fc76a9632e Mon Sep 17 00:00:00 2001
From: panticmilos <panticmilos@github.com>
Date: Fri, 25 Nov 2022 10:50:21 +0100
Subject: [PATCH] Apply internal discussion agreements

---
 .github/workflows/versions.yml |  2 --
 __tests__/setup-go.test.ts     |  2 +-
 src/installer.ts               |  4 ++--
 src/main.ts                    | 11 +++--------
 src/utils.ts                   |  2 --
 5 files changed, 6 insertions(+), 15 deletions(-)

diff --git a/.github/workflows/versions.yml b/.github/workflows/versions.yml
index e724d3b..1291b08 100644
--- a/.github/workflows/versions.yml
+++ b/.github/workflows/versions.yml
@@ -24,7 +24,6 @@ jobs:
         uses: ./
         with:
           go-version: stable
-          architecture: x64
       - name: Verify Go
         run: go version
 
@@ -40,7 +39,6 @@ jobs:
         uses: ./
         with:
           go-version: oldstable
-          architecture: x64
       - name: Verify Go
         run: go version
 
diff --git a/__tests__/setup-go.test.ts b/__tests__/setup-go.test.ts
index f10f85c..2188fc9 100644
--- a/__tests__/setup-go.test.ts
+++ b/__tests__/setup-go.test.ts
@@ -722,7 +722,7 @@ describe('setup-go', () => {
       expect(logSpy).toHaveBeenCalledWith('Adding to the cache ...');
       expect(logSpy).toHaveBeenCalledWith('Added go to the path');
       expect(logSpy).toHaveBeenCalledWith(
-        `Successfully set up Go version ${patchVersion}`
+        `Successfully set up Go version ${versionSpec}`
       );
     });
 
diff --git a/src/installer.ts b/src/installer.ts
index 37fa6e6..23b8fd0 100644
--- a/src/installer.ts
+++ b/src/installer.ts
@@ -129,7 +129,7 @@ export async function getGo(
   return downloadPath;
 }
 
-export async function resolveVersionFromManifest(
+async function resolveVersionFromManifest(
   versionSpec: string,
   stable: boolean,
   auth: string | undefined,
@@ -358,7 +358,7 @@ export async function resolveStableVersionInput(
   versionSpec: string,
   auth: string | undefined,
   arch = os.arch(),
-  manifest: tc.IToolRelease[] | undefined
+  manifest: tc.IToolRelease[] | undefined,
 ): Promise<string> {
   if (!manifest) {
     core.debug('No manifest cached');
diff --git a/src/main.ts b/src/main.ts
index a5816b8..613cb54 100644
--- a/src/main.ts
+++ b/src/main.ts
@@ -8,7 +8,6 @@ import {isCacheFeatureAvailable} from './cache-utils';
 import cp from 'child_process';
 import fs from 'fs';
 import os from 'os';
-import {IS_WINDOWS} from './utils';
 
 export async function run() {
   try {
@@ -16,7 +15,7 @@ export async function run() {
     // versionSpec is optional.  If supplied, install / use from the tool cache
     // If not supplied then problem matchers will still be setup.  Useful for self-hosted.
     //
-    let versionSpec = resolveVersionInput();
+    const versionSpec = resolveVersionInput();
 
     const cache = core.getBooleanInput('cache');
     core.info(`Setup go version spec ${versionSpec}`);
@@ -43,16 +42,12 @@ export async function run() {
         manifest
       );
 
-      if (IS_WINDOWS) {
-        versionSpec = installDir.split('\\').reverse()[1];
-      } else {
-        versionSpec = installDir.split('/').reverse()[1];
-      }
+      const installDirVersion = path.basename(path.dirname(installDir));
 
       core.addPath(path.join(installDir, 'bin'));
       core.info('Added go to the path');
 
-      const version = installer.makeSemver(versionSpec);
+      const version = installer.makeSemver(installDirVersion);
       // Go versions less than 1.9 require GOROOT to be set
       if (semver.lt(version, '1.9.0')) {
         core.info('Setting GOROOT for Go version < 1.9');
diff --git a/src/utils.ts b/src/utils.ts
index 6f6315c..79d03bc 100644
--- a/src/utils.ts
+++ b/src/utils.ts
@@ -2,5 +2,3 @@ export enum StableReleaseAlias {
   Stable = 'stable',
   OldStable = 'oldstable'
 }
-
-export const IS_WINDOWS = process.platform === 'win32';