golang / vscode-go

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

Clarify unsupported Go versions in README and error messages #3409

Closed williandandrade closed 1 month ago

williandandrade commented 1 month 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.18 darwin/arm64` * Run `gopls -v version` to get version of Gopls from _the VS Code integrated terminal_. - N/A * Run `code -v` or `code-insiders -v` to get version of VS Code or VS Code Insiders. - `1.89.1` - `dc96b837cf6bb4af9cd736aa3af08cf8279f7685` - `arm64` * Check your installed extensions to get the version of the VS Code Go extension - `v0.41.4` * Run Ctrl+Shift+P (Cmd+Shift+P on Mac OS) > `Go: Locate Configured Go Tools` command. ```markdown # Tools Configuration ## Environment GOBIN: undefined toolsGopath: gopath: /Users/wa/.asdf/installs/golang/1.18/packages GOROOT: /Users/wa/.asdf/installs/golang/1.18/go PATH: /Users/wa/.asdf/installs/golang/1.18/go/bin:/Users/wa/google-cloud-sdk/bin:/Users/wa/.asdf/shims:/opt/homebrew/opt/asdf/libexec/bin:/Users/wa/google-cloud-sdk/bin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Library/Apple/usr/bin:/Applications/Wireshark.app/Contents/MacOS:/usr/local/go/bin:/Applications/iTerm.app/Contents/Resources/utilities:/Users/wa/Library/Application Support/JetBrains/Toolbox/scripts:/opt/homebrew/bin:/opt/homebrew/sbin:/opt/homebrew/bin:/opt/homebrew/sbin PATH (vscode launched with): /Users/wa/google-cloud-sdk/bin:/Users/wa/.asdf/shims:/opt/homebrew/opt/asdf/libexec/bin:/Users/wa/google-cloud-sdk/bin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Library/Apple/usr/bin:/Applications/Wireshark.app/Contents/MacOS:/usr/local/go/bin:/Applications/iTerm.app/Contents/Resources/utilities:/Users/wa/Library/Application Support/JetBrains/Toolbox/scripts:/opt/homebrew/bin:/opt/homebrew/sbin:/opt/homebrew/bin:/opt/homebrew/sbin ## Tools go: /Users/wa/.asdf/installs/golang/1.18/go/bin/go: go version go1.18 darwin/arm64 gopls: not installed gotests: /Users/wa/.asdf/installs/golang/1.18/go/bin/gotests (version: v1.6.0 built with go: go1.18) gomodifytags: /Users/wa/.asdf/installs/golang/1.18/go/bin/gomodifytags (version: v1.16.0 built with go: go1.18) impl: /Users/wa/.asdf/installs/golang/1.18/go/bin/impl (version: v1.1.0 built with go: go1.18) goplay: /Users/wa/.asdf/installs/golang/1.18/go/bin/goplay (version: v1.0.0 built with go: go1.18) dlv: /Users/wa/.asdf/installs/golang/1.18/go/bin/dlv (version: v1.22.1 built with go: go1.18) staticcheck: /Users/wa/.asdf/installs/golang/1.18/packages/bin/staticcheck (version: v0.3.3 built with go: go1.18) ## Go env Workspace Folder (go): /Users/wa/projects/go GO111MODULE="" GOARCH="arm64" GOBIN="" GOCACHE="/Users/wa/Library/Caches/go-build" GOENV="/Users/wa/Library/Application Support/go/env" GOEXE="" GOEXPERIMENT="" GOFLAGS="" GOHOSTARCH="arm64" GOHOSTOS="darwin" GOINSECURE="" GOMODCACHE="/Users/wa/.asdf/installs/golang/1.18/go/pkg/mod" GONOPROXY="" GONOSUMDB="" GOOS="darwin" GOPATH="/Users/wa/.asdf/installs/golang/1.18/packages" GOPRIVATE="" GOPROXY="https://proxy.golang.org,direct" GOROOT="/Users/wa/.asdf/installs/golang/1.18/go" GOSUMDB="sum.golang.org" GOTMPDIR="" GOTOOLDIR="/Users/wa/.asdf/installs/golang/1.18/go/pkg/tool/darwin_arm64" GOVCS="" GOVERSION="go1.18" GCCGO="gccgo" AR="ar" CC="clang" CXX="clang++" CGO_ENABLED="1" GOMOD="/Users/wa/projects/go/go.mod" GOWORK="" CGO_CFLAGS="-g -O2" CGO_CPPFLAGS="" CGO_CXXFLAGS="-g -O2" CGO_FFLAGS="-g -O2" CGO_LDFLAGS="-g -O2" PKG_CONFIG="pkg-config" GOGCCFLAGS="-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/bn/6lg_h65j28l9wklnqv94jp9c0000gn/T/go-build3642746910=/tmp/go-build -gno-record-gcc-switches -fno-common" ```

Describe the bug

Can't use the extension with Go 1.18 because gopls@latest have a dependency to atomic.Int32.

2024-05-27 12:56:41.704 [info] Tools environment: GOPATH=/Users/wa/.asdf/installs/golang/1.18/go
2024-05-27 12:56:41.704 [info] Installing 1 tool at /Users/wa/.asdf/installs/golang/1.18/go/bin
2024-05-27 12:56:41.704 [info]   gopls
2024-05-27 12:56:41.704 [info] 
2024-05-27 12:56:42.418 [info] Installing golang.org/x/tools/gopls@latest FAILED
2024-05-27 12:56:42.418 [info] {
 "code": 2,
 "killed": false,
 "signal": null,
 "cmd": "/Users/wa/.asdf/installs/golang/1.18/go/bin/go install -v golang.org/x/tools/gopls@latest",
 "stdout": "",
 "stderr": "golang.org/x/tools/gopls/internal/cache\n# golang.org/x/tools/gopls/internal/cache\n../../.asdf/installs/golang/1.18/go/pkg/mod/golang.org/x/tools/gopls@v0.15.3/internal/cache/analysis.go:389:23: undefined: atomic.Int64\n../../.asdf/installs/golang/1.18/go/pkg/mod/golang.org/x/tools/gopls@v0.15.3/internal/cache/analysis.go:525:25: undefined: atomic.Int32\n../../.asdf/installs/golang/1.18/go/pkg/mod/golang.org/x/tools/gopls@v0.15.3/internal/cache/analysis.go:526:25: undefined: atomic.Int32\n"
}
2024-05-27 12:56:42.421 [info] 
2024-05-27 12:56:42.421 [info] 1 tools failed to install.

2024-05-27 12:56:42.421 [info] gopls: failed to install gopls(golang.org/x/tools/gopls@latest): Error: Command failed: /Users/wa/.asdf/installs/golang/1.18/go/bin/go install -v golang.org/x/tools/gopls@latest
golang.org/x/tools/gopls/internal/cache
# golang.org/x/tools/gopls/internal/cache
../../.asdf/installs/golang/1.18/go/pkg/mod/golang.org/x/tools/gopls@v0.15.3/internal/cache/analysis.go:389:23: undefined: atomic.Int64
../../.asdf/installs/golang/1.18/go/pkg/mod/golang.org/x/tools/gopls@v0.15.3/internal/cache/analysis.go:525:25: undefined: atomic.Int32
../../.asdf/installs/golang/1.18/go/pkg/mod/golang.org/x/tools/gopls@v0.15.3/internal/cache/analysis.go:526:25: undefined: atomic.Int32

Steps to reproduce the behavior:

  1. Install go@1.18 from scratch
  2. Install the extension in VSCode
  3. Try to install the tools by opening some go file or go.mod
williandandrade commented 1 month ago

related to: https://github.com/golang/vscode-go/issues/3412

hyangah commented 1 month ago

Use go.toolsManagement.go setting to tell the extension to use a newer version of go when building tools. https://github.com/golang/vscode-go/wiki/settings#gotoolsmanagementgo Or, manually install the right version of gopls and tools suitable for go 1.18.

Will update README that users need go1.19+ if they want the extension to handle tools installation.

gopherbot commented 1 month ago

Change https://go.dev/cl/588757 mentions this issue: extension/src: require go1.19+ for tools installation