diff --git a/dist/setup/index.js b/dist/setup/index.js
index 38e8143..40f31c5 100644
--- a/dist/setup/index.js
+++ b/dist/setup/index.js
@@ -63602,17 +63602,17 @@ function run() {
                 core.debug(`add bin ${added}`);
                 core.info(`Successfully set up Go version ${versionSpec}`);
             }
+            let goPath = yield io.which('go');
+            let goVersion = (child_process_1.default.execSync(`${goPath} version`) || '').toString();
             if (cache && cache_utils_1.isCacheFeatureAvailable()) {
                 const packageManager = 'default';
                 const cacheDependencyPath = core.getInput('cache-dependency-path');
-                yield cache_restore_1.restoreCache(versionSpec, packageManager, cacheDependencyPath);
+                yield cache_restore_1.restoreCache(parseGoVersion(goVersion), packageManager, cacheDependencyPath);
             }
             // add problem matchers
             const matchersPath = path_1.default.join(__dirname, '../..', 'matchers.json');
             core.info(`##[add-matcher]${matchersPath}`);
             // output the version actually being used
-            const goPath = yield io.which('go');
-            const goVersion = (child_process_1.default.execSync(`${goPath} version`) || '').toString();
             core.info(goVersion);
             core.setOutput('go-version', parseGoVersion(goVersion));
             core.startGroup('go env');
diff --git a/src/main.ts b/src/main.ts
index 6558753..6cdb2e6 100644
--- a/src/main.ts
+++ b/src/main.ts
@@ -56,10 +56,17 @@ export async function run() {
       core.info(`Successfully set up Go version ${versionSpec}`);
     }
 
+    let goPath = await io.which('go');
+    let goVersion = (cp.execSync(`${goPath} version`) || '').toString();
+
     if (cache && isCacheFeatureAvailable()) {
       const packageManager = 'default';
       const cacheDependencyPath = core.getInput('cache-dependency-path');
-      await restoreCache(versionSpec, packageManager, cacheDependencyPath);
+      await restoreCache(
+        parseGoVersion(goVersion),
+        packageManager,
+        cacheDependencyPath
+      );
     }
 
     // add problem matchers
@@ -67,8 +74,6 @@ export async function run() {
     core.info(`##[add-matcher]${matchersPath}`);
 
     // output the version actually being used
-    const goPath = await io.which('go');
-    const goVersion = (cp.execSync(`${goPath} version`) || '').toString();
     core.info(goVersion);
 
     core.setOutput('go-version', parseGoVersion(goVersion));