From 8ee4dafb9bf99b2a3c6aeca04c0a2029bdc3c327 Mon Sep 17 00:00:00 2001 From: Ramya Achutha Rao Date: Sun, 16 Jul 2017 22:39:16 -0700 Subject: [PATCH] Update tools prompt when go version is different Fixes #797 --- src/goMain.ts | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/goMain.ts b/src/goMain.ts index fcf62a422..bdda0e2c0 100644 --- a/src/goMain.ts +++ b/src/goMain.ts @@ -27,7 +27,7 @@ import { testAtCursor, testCurrentPackage, testCurrentFile, testPrevious, showTe import * as goGenerateTests from './goGenerateTests'; import { addImport } from './goImport'; import { installAllTools, checkLanguageServer } from './goInstallTools'; -import { isGoPathSet, getBinPath, sendTelemetryEvent, getExtensionCommands } from './util'; +import { isGoPathSet, getBinPath, sendTelemetryEvent, getExtensionCommands, getGoVersion } from './util'; import { LanguageClient } from 'vscode-languageclient'; import { clearCacheForTools } from './goPath'; import { addTags, removeTags } from './goModifytags'; @@ -45,6 +45,23 @@ export function activate(ctx: vscode.ExtensionContext): void { let toolsGopath = vscode.workspace.getConfiguration('go')['toolsGopath']; updateGoPathGoRootFromConfig().then(() => { + getGoVersion().then(currentVersion => { + if (currentVersion) { + const prevVersion = ctx.globalState.get('goVersion'); + const currVersionString = `${currentVersion.major}.${currentVersion.minor}`; + + if (prevVersion !== currVersionString) { + if (prevVersion) { + vscode.window.showInformationMessage('Your Go version is different than before, few Go tools may need re-compiling', 'Update tools').then(selected => { + if (selected === 'Rebuild tools') { + vscode.commands.executeCommand('go.tools.install'); + } + }); + } + ctx.globalState.update('goVersion', currVersionString); + } + } + }); goListAll(); offerToInstallTools(); let langServerAvailable = checkLanguageServer();