Skip to content

Commit 93a6e13

Browse files
committed
package.json: add go.terminal.activateEnvironment setting
The Go extension attempts to add the path to the chosen Go binary (typically, $GOROOT/bin) to the PATH or Path environment variable used in the integrated terminal - to help users pick up the same Go binary the extension uses when they run 'go' from the integrated terminal. Some users however report this default behavior interferes with other Go version manamange systems or their shell setup. This new `go.terminal.activateEnvironment` setting allows users to disable the default behavior. The default is true to preserve the current default behavior. Unfortunately, there is no test - this code path was hard to test reliably. Fixes #1558 Fixes #1098 Change-Id: Ic35b11c47f9393655e6b3e37b12c369a37b56132 Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/336409 Trust: Hyang-Ah Hana Kim <[email protected]> Run-TryBot: Hyang-Ah Hana Kim <[email protected]> TryBot-Result: kokoro <[email protected]> Reviewed-by: Rebecca Stambler <[email protected]> Reviewed-by: Suzy Mueller <[email protected]>
1 parent 29634d6 commit 93a6e13

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

docs/settings.md

+5
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,11 @@ Default:
382382
"tags" : "",
383383
}
384384
```
385+
### `go.terminal.activateEnvironment`
386+
387+
Apply the Go & PATH environment variables used by the extension to all integrated terminals.
388+
389+
Default: `true`
385390
### `go.testEnvFile`
386391

387392
Absolute path to a file containing environment variables definitions. File contents should be of the form key=value.

package.json

+6
Original file line numberDiff line numberDiff line change
@@ -1819,6 +1819,12 @@
18191819
},
18201820
"additionalProperties": true
18211821
},
1822+
"go.terminal.activateEnvironment": {
1823+
"default": true,
1824+
"description": "Apply the Go & PATH environment variables used by the extension to all integrated terminals.",
1825+
"scope": "resource",
1826+
"type": "boolean"
1827+
},
18221828
"gopls": {
18231829
"type": "object",
18241830
"markdownDescription": "Configure the default Go language server ('gopls'). In most cases, configuring this section is unnecessary. See [the documentation](https://github.com/golang/tools/blob/master/gopls/doc/settings.md) for all available settings.",

src/goEnvironmentStatus.ts

+4
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,10 @@ export function addGoRuntimeBaseToPATH(newGoRuntimeBase: string) {
323323
if (!newGoRuntimeBase) {
324324
return;
325325
}
326+
const goCfg = getGoConfig();
327+
if (!goCfg.get('terminal.activateEnvironment')) {
328+
return;
329+
}
326330
const pathEnvVar = pathEnvVarName();
327331
if (!pathEnvVar) {
328332
logVerbose("couldn't find PATH property in process.env");

0 commit comments

Comments
 (0)