src/goEnv.ts: readd go.toolsEnvVars variable substitution

The extension resolved ${workspaceFolder}, ${workspaceRoot},
${env:} variables included in go.toolsEnvVars, since 0.6.66,
but that feature was lost in the 0.15 dev cycle.

Readd the code from
https://github.com/microsoft/vscode-go/blob/2dbccbe5d2fb70feab3f87ac6f6187f6b896e795/src/util.ts#L438

Similar logic for testEnvVars still exists in getTestEnvVars
(testutils.ts).

Fixes golang/vscode-go#413

Change-Id: I1cc8ff41ce8445c573e554f947da8cd610c3671b
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/246519
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
diff --git a/src/goEnv.ts b/src/goEnv.ts
index b872319..0372895 100644
--- a/src/goEnv.ts
+++ b/src/goEnv.ts
@@ -7,7 +7,7 @@
 
 import path = require('path');
 import vscode = require('vscode');
-import { getCurrentGoPath, getGoConfig, getToolsGopath } from './util';
+import { getCurrentGoPath, getGoConfig, getToolsGopath, resolvePath } from './util';
 
 // toolInstallationEnvironment returns the environment in which tools should
 // be installed. It always returns a new object.
@@ -56,6 +56,13 @@
 function newEnvironment(): NodeJS.Dict<string> {
 	const toolsEnvVars = getGoConfig()['toolsEnvVars'];
 	const env = Object.assign({}, process.env, toolsEnvVars);
+	if (toolsEnvVars && typeof toolsEnvVars === 'object') {
+		Object.keys(toolsEnvVars).forEach(
+			(key) =>
+				(env[key] =
+					typeof toolsEnvVars[key] === 'string' ? resolvePath(toolsEnvVars[key]) : toolsEnvVars[key])
+		);
+	}
 
 	// The http.proxy setting takes precedence over environment variables.
 	const httpProxy = vscode.workspace.getConfiguration('http', null).get('proxy');