Open JohnstonJ opened 2 months ago
I think it's a reasonable request. On the other hand, there are many other GO* environment variables. (for example, GOMODCACHE, GOPRIVATE, .. are some of the commonly modified Go environment variables.) Should these be also applied to the terminals?
I think it is a bug on Windows. I vaguely remember that I used to directly invoke go in ps.
Here on linux, PATH is correctly set in terminals.
But on Windows, PATH is not updated.
@TLCFEM I think that is a separate issue. This issue is about GOPATH
, not the Path
/PATH
handling. For your issue, can you please open a separate issue to follow up?
I think it's a reasonable request. On the other hand, there are many other GO* environment variables. (for example, GOMODCACHE, GOPRIVATE, .. are some of the commonly modified Go environment variables.) Should these be also applied to the terminals?
It seems to me like any environment variable that is controlled by the extension's configuration might be worthy of consideration to set in the terminal.
What version of Go, VS Code & VS Code Go extension are you using?
Version Information
* Run `go version` to get version of Go from _the VS Code integrated terminal_. - `go version go1.23.0 windows/amd64` * Run `gopls -v version` to get version of Gopls from _the VS Code integrated terminal_. - `golang.org/x/tools/gopls v0.16.1` * Run `code -v` or `code-insiders -v` to get version of VS Code or VS Code Insiders. ``` 1.92.2 fee1edb8d6d72a0ddff41e5f71a671c23ed924b9 x64 ``` * Check your installed extensions to get the version of the VS Code Go extension - `v0.42.0` * Run Ctrl+Shift+P (Cmd+Shift+P on Mac OS) > `Go: Locate Configured Go Tools` command. ``` # Tools Configuration ## Environment GOBIN: undefined toolsGopath: gopath: C:\Users\JohnstonJ\Documents\Projects\dv-toolbox\.tools\gopath GOROOT: C:\Users\JohnstonJ\Documents\Projects\dv-toolbox\.tools\goroot PATH: C:\Users\JohnstonJ\Documents\Projects\dv-toolbox\.tools\goroot\bin;C:\Program Files\PowerShell\7;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\Git\cmd;C:\Program Files\dotnet\;C:\Program Files\PowerShell\7\;C:\Program Files\Docker\Docker\resources\bin;C:\Users\JohnstonJ\AppData\Local\Programs\Python\Launcher\;C:\Users\JohnstonJ\AppData\Local\Microsoft\WindowsApps PATH (vscode launched with): C:\Program Files\PowerShell\7;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\Git\cmd;C:\Program Files\dotnet\;C:\Program Files\PowerShell\7\;C:\Program Files\Docker\Docker\resources\bin;C:\Users\JohnstonJ\AppData\Local\Programs\Python\Launcher\;C:\Users\JohnstonJ\AppData\Local\Microsoft\WindowsApps ## Tools go: C:\Users\JohnstonJ\Documents\Projects\dv-toolbox\.tools\goroot\bin\go.exe: go version go1.23.0 windows/amd64 gopls: C:\Users\JohnstonJ\Documents\Projects\dv-toolbox\.tools\gopath\bin\gopls.exe (version: v0.16.1 built with go: go1.23.0) gotests: not installed gomodifytags: not installed impl: not installed goplay: not installed dlv: not installed staticcheck: C:\Users\JohnstonJ\Documents\Projects\dv-toolbox\.tools\gopath\bin\staticcheck.exe (version: v0.5.1 built with go: go1.23.0) ## Go env Workspace Folder (dv-toolbox): c:\Users\JohnstonJ\Documents\Projects\dv-toolbox set GO111MODULE= set GOARCH=amd64 set GOBIN= set GOCACHE=C:\Users\JohnstonJ\AppData\Local\go-build set GOENV=C:\Users\JohnstonJ\AppData\Roaming\go\env set GOEXE=.exe set GOEXPERIMENT= set GOFLAGS= set GOHOSTARCH=amd64 set GOHOSTOS=windows set GOINSECURE= set GOMODCACHE=C:\Users\JohnstonJ\Documents\Projects\dv-toolbox\.tools\gopath\pkg\mod set GONOPROXY= set GONOSUMDB= set GOOS=windows set GOPATH=C:\Users\JohnstonJ\Documents\Projects\dv-toolbox\.tools\gopath set GOPRIVATE= set GOPROXY=https://proxy.golang.org,direct set GOROOT=C:\Users\JohnstonJ\Documents\Projects\dv-toolbox\.tools\goroot set GOSUMDB=sum.golang.org set GOTMPDIR= set GOTOOLCHAIN=auto set GOTOOLDIR=C:\Users\JohnstonJ\Documents\Projects\dv-toolbox\.tools\goroot\pkg\tool\windows_amd64 set GOVCS= set GOVERSION=go1.23.0 set GODEBUG= set GOTELEMETRY=local set GOTELEMETRYDIR=C:\Users\JohnstonJ\AppData\Roaming\go\telemetry set GCCGO=gccgo set GOAMD64=v1 set AR=ar set CC=gcc set CXX=g++ set CGO_ENABLED=0 set GOMOD=c:\Users\JohnstonJ\Documents\Projects\dv-toolbox\go.mod set GOWORK= set CGO_CFLAGS=-O2 -g set CGO_CPPFLAGS= set CGO_CXXFLAGS=-O2 -g set CGO_FFLAGS=-O2 -g set CGO_LDFLAGS=-O2 -g set PKG_CONFIG=pkg-config set GOGCCFLAGS=-m64 -fno-caret-diagnostics -Qunused-arguments -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=C:\Users\JOHNST~1\AppData\Local\Temp\go-build2632435785=/tmp/go-build -gno-record-gcc-switches ```
Share the Go related settings you have added/edited
Run
Preferences: Open Settings (JSON)
command to open your settings.json file. Share all the settings with thego.
or["go"]
orgopls
prefixes.Describe the bug
I am using Go in a portable fashion - I've downloaded Go and put it into a subdirectory of my repo, along with creating a special GOPATH.
Unfortunately, terminals created in VS Code don't have the GOPATH environment variable properly set. They do have the PATH variable updated with the new $GOROOT\bin. But not the GOPATH.
My expectation is that the terminals should have the custom GOPATH as well.
Steps to reproduce the behavior:
go.gopath
setting.go env
when run from inside the terminal will print the wrong GOPATH value.Likely root cause
There is a function called
updateIntegratedTerminal
at https://github.com/golang/vscode-go/blob/725259766181b4be91ed84411d6ac564a5ab2e5a/extension/src/goEnvironmentStatus.ts#L371-L400 It updates the PATH for the current GOROOT. But there doesn't appear to be any code for updating GOPATH. Perhaps it was simply never implemented?Screenshots or recordings