golang / vscode-go

Go extension for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=golang.Go
Other
3.85k stars 738 forks source link

settings: support predefined variables in go.toolsEnvVars #3047

Closed WittonBell closed 10 months ago

WittonBell commented 10 months ago

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.21.3 windows/amd64 * Run `gopls -v version` to get version of Gopls from _the VS Code integrated terminal_. - Build info ---------- golang.org/x/tools/gopls v0.14.1 golang.org/x/tools/gopls@v0.14.1 h1:XaTETpi7Q67XO8nftquJitcx+9c2bPclO8Kz2sBVvec= github.com/BurntSushi/toml@v1.2.1 h1:9F2/+DoOYIOksmaJFPw1tGFy1eDnIJXg+UHjuD8lTak= github.com/google/go-cmp@v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/sergi/go-diff@v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0= golang.org/x/exp/typeparams@v0.0.0-20221212164502-fae10dda9338 h1:2O2DON6y3XMJiQRAS1UWU+54aec2uopH3x7MAiqGW6Y= golang.org/x/mod@v0.13.0 h1:I/DsJXRlw/8l/0c24sM9yb0T4z9liZTduXvdAWYiysY= golang.org/x/sync@v0.4.0 h1:zxkM55ReGkDlKSM+Fu41A+zmbZuaPVbGMzvvdUPznYQ= golang.org/x/sys@v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= golang.org/x/telemetry@v0.0.0-20231011160506-788d5629a052 h1:1baVNneD/IRxmu8JQdBuki78zUqBtZxq8smZXQj0X2Y= golang.org/x/text@v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= golang.org/x/tools@v0.14.1-0.20231026192422-8b5abd452b28 h1:5YgdZAe2w0x3Xrjv0+GXrI0jvm7qCQK/ySGFfiEHMfU= golang.org/x/vuln@v1.0.1 h1:KUas02EjQK5LTuIx1OylBQdKKZ9jeugs+HiqO5HormU= honnef.co/go/tools@v0.4.5 h1:YGD4H+SuIOOqsyoLOpZDWcieM28W47/zRO7f+9V3nvo= mvdan.cc/gofumpt@v0.4.0 h1:JVf4NN1mIpHogBj7ABpgOyZc65/UUOkKQFkoURsz4MM= mvdan.cc/xurls/v2@v2.4.0 h1:tzxjVAj+wSBmDcF6zBB7/myTy3gX9xvi8Tyr28AuQgc= go: go1.21.3 * Run `code -v` or `code-insiders -v` to get version of VS Code or VS Code Insiders. - * Check your installed extensions to get the version of the VS Code Go extension - v0.39.1 * Run Ctrl+Shift+P (Cmd+Shift+P on Mac OS) > `Go: Locate Configured Go Tools` command. - Checking configured tools.... GOBIN: undefined toolsGopath: gopath: C:\Users\admin\go GOROOT: G:/msys64/mingw64/lib/go PATH: G:\msys64\mingw64\lib\go\bin;C:\Program Files\Python\Python310\Scripts\;C:\Program Files\Python\Python310\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Users\admin\.dnx\bin;C:\Program Files\Microsoft DNX\Dnvm\;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files\Git\cmd;C:\Program Files\VSCode\bin;C:\Program Files\Pandoc\;C:\Program Files\Microsoft SQL Server\150\Tools\Binn\;C:\ProgramData\chocolatey\bin;C:\Program Files\Docker\cli-plugins;C:\Program Files\TortoiseGit\bin;C:\Program Files\dotnet\;C:\Program Files\Python\Scripts\;C:\Program Files\Python\;C:\Users\admin\AppData\Local\Microsoft\WindowsApps;C:\Users\admin\.dotnet\tools; PATH (vscode launched with): C:\Program Files\Python\Python310\Scripts\;C:\Program Files\Python\Python310\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Users\admin\.dnx\bin;C:\Program Files\Microsoft DNX\Dnvm\;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files\Git\cmd;C:\Program Files\VSCode\bin;C:\Program Files\Pandoc\;C:\Program Files\Microsoft SQL Server\150\Tools\Binn\;C:\ProgramData\chocolatey\bin;C:\Program Files\Docker\cli-plugins;C:\Program Files\TortoiseGit\bin;C:\Program Files\dotnet\;C:\Program Files\Python\Scripts\;C:\Program Files\Python\;C:\Users\admin\AppData\Local\Microsoft\WindowsApps;C:\Program Files\JetBrains\GoLand 2021.2.3\bin;;C:\Users\admin\AppData\Roaming\npm;C:\Users\admin\.dotnet\tools; go: G:\msys64\mingw64\lib\go\bin\go.exe: go version go1.21.3 windows/amd64 gotests: C:\Users\admin\go\bin\gotests.exe (version: v1.6.0 built with go: go1.21.3) gomodifytags: C:\Users\admin\go\bin\gomodifytags.exe (version: v1.16.0 built with go: go1.21.3) impl: C:\Users\admin\go\bin\impl.exe (version: v1.1.0 built with go: go1.21.3) goplay: C:\Users\admin\go\bin\goplay.exe (version: v1.0.0 built with go: go1.21.3) dlv: C:\Users\admin\go\bin\dlv.exe (version: v1.21.2 built with go: go1.21.3) staticcheck: C:\Users\admin\go\bin\staticcheck.exe (version: v0.4.6 built with go: go1.21.3) gopls: C:\Users\admin\go\bin\gopls.exe (version: v0.14.1 built with go: go1.21.3) go env Workspace Folder (t): d:\t set GO111MODULE=on set GOARCH=amd64 set GOBIN= set GOCACHE=C:\Users\admin\AppData\Local\go-build set GOENV=C:\Users\admin\AppData\Roaming\go\env set GOEXE=.exe set GOEXPERIMENT= set GOFLAGS= set GOHOSTARCH=amd64 set GOHOSTOS=windows set GOINSECURE= set GOMODCACHE=C:\Users\admin\go\pkg\mod set GONOPROXY= set GONOSUMDB= set GOOS=windows set GOPATH=C:\Users\admin\go set GOPRIVATE= set GOPROXY=https://goproxy.cn,direct set GOROOT=G:/msys64/mingw64/lib/go set GOSUMDB=sum.golang.org set GOTMPDIR= set GOTOOLCHAIN=auto set GOTOOLDIR=G:\msys64\mingw64\lib\go\pkg\tool\windows_amd64 set GOVCS= set GOVERSION=go1.21.3 set GCCGO=gccgo set GOAMD64=v1 set AR=ar set CC=gcc set CXX=g++ set CGO_ENABLED=1 set GOMOD=d:\t\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 -mthreads -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=C:\Users\admin\AppData\Local\Temp\go-build820196356=/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 the go. or ["go"] or gopls prefixes.

"terminal.integrated.defaultProfile.windows": "Command Prompt",
  "terminal.integrated.env.windows": {
    "PATH":"G:/msys64/mingw64/bin/;C:/Users/admin/go/bin;${env:PATH}"
  },
"go.goroot": "G:/msys64/mingw64/lib/go",
"go.toolsEnvVars": {
    "PATH" : "G:/msys64/mingw64/bin/;C:/Users/admin/go;${env:PATH}"
  },

Describe the bug

${env:PATH} in go.toolsEnvVars not be substitution with predefined PATH

There have been such bug 413 before.There are still issues at present.

Steps to reproduce the behavior:

  1. create a go project with main.go in VSCode
    
    package main

import ( "fmt" "os" )

func main() { path := os.Getenv("path") fmt.Printf("PATH:%s", path) }


2. start go debugger in VSCode
3. see the `debug console`, the output `PATH` is:
`PATH:G:/msys64/mingw64/bin/;C:/Users/admin/go;${env:PATH}`

### Screenshots or recordings
If applicable, add screenshots or recordings to help explain your problem.
suzmue commented 10 months ago

This is a duplicate of #2680 which was addressed in the latest release v0.40.0.