src/goEnvironmentStatus: fix old/new GOROOT comparison

getCurrentGoRoot is GOROOT and getBinPathFromEnvVar returns
the path to the go binary. So, we need to compare the directory
names to check if they match.

While we are here, let's register the status bar item dispose
callback.

Change-Id: Iba0ee4e7878fd386fa49f21ea898f031737fa50d
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/243637
Reviewed-by: Brayden Cloud <bcloud@google.com>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
diff --git a/src/goEnvironmentStatus.ts b/src/goEnvironmentStatus.ts
index 5e2a6f8..7eef510 100644
--- a/src/goEnvironmentStatus.ts
+++ b/src/goEnvironmentStatus.ts
@@ -278,8 +278,9 @@
  */
 export async function updateIntegratedTerminal(terminal: vscode.Terminal) {
 	if (!terminal) { return; }
-	const goroot = path.join(getCurrentGoRoot(), 'bin');
-	if (goroot === getBinPathFromEnvVar('go', terminalPATH, false)) {
+	const gorootBin = path.join(getCurrentGoRoot(), 'bin');
+	const defaultGoRuntimeBin = path.dirname(getBinPathFromEnvVar('go', terminalPATH, false));
+	if (gorootBin === defaultGoRuntimeBin) {
 		return;
 	}
 
@@ -287,16 +288,16 @@
 	// TODO: add support for more terminal names
 	// this assumes all non-windows shells are bash-like.
 	if (terminal.name.toLowerCase() === 'cmd') {
-		terminal.sendText(`set PATH=${goroot};%Path%`, true);
+		terminal.sendText(`set PATH=${gorootBin};%Path%`, true);
 		terminal.sendText('cls');
 	} else if (terminal.name.toLowerCase() === 'powershell') {
-		terminal.sendText(`$env:Path="${goroot};$env:Path"`, true);
+		terminal.sendText(`$env:Path="${gorootBin};$env:Path"`, true);
 		terminal.sendText('clear');
 	} else if (terminal.name.toLowerCase() === 'fish') {
-		terminal.sendText(`set -gx PATH ${goroot} $PATH`);
+		terminal.sendText(`set -gx PATH ${gorootBin} $PATH`);
 		terminal.sendText('clear');
 	} else {
-		terminal.sendText(`export PATH=${goroot}:$PATH`, true);
+		terminal.sendText(`export PATH=${gorootBin}:$PATH`, true);
 		terminal.sendText('clear');
 	}
 }
diff --git a/src/goMain.ts b/src/goMain.ts
index 88a528c..bcf5031 100644
--- a/src/goMain.ts
+++ b/src/goMain.ts
@@ -19,7 +19,7 @@
 import { GoDebugConfigurationProvider } from './goDebugConfiguration';
 import { extractFunction, extractVariable } from './goDoctor';
 import { toolExecutionEnvironment } from './goEnv';
-import { chooseGoEnvironment } from './goEnvironmentStatus';
+import { chooseGoEnvironment, disposeGoStatusBar } from './goEnvironmentStatus';
 import { runFillStruct } from './goFillStruct';
 import * as goGenerateTests from './goGenerateTests';
 import { goGetPackage } from './goGetPackage';
@@ -601,7 +601,10 @@
 }
 
 export function deactivate() {
-	return Promise.all([cancelRunningTests(), Promise.resolve(cleanupTempDir())]);
+	return Promise.all([
+		cancelRunningTests(),
+		Promise.resolve(cleanupTempDir()),
+		Promise.resolve(disposeGoStatusBar())]);
 }
 
 function runBuilds(document: vscode.TextDocument, goConfig: vscode.WorkspaceConfiguration) {