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 #3412

Closed williandandrade closed 1 month ago

williandandrade commented 1 month ago

gopls version

n/a

go env

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/packages/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-build654916903=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

Due to an onboarding on a project I fresh installed go@1.18 in my environment using asdf and tried to setup the VSCode's extension to start coding.

What did you see happen?

Error when installing gopls@latest.

What did you expect to see?

All the tools installed properly.

Editor and settings

No response

Logs

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
fzipp commented 1 month ago

The Go project only supports the last two major releases, currently 1.22 and 1.21: https://go.dev/doc/devel/release#policy

gopls@latest requires at least Go 1.19: https://cs.opensource.google/go/x/tools/+/master:gopls/go.mod;l=3 The atomic.Int{32|64} types were added in Go 1.19: https://pkg.go.dev/sync/atomic#Int64

findleyr commented 1 month ago

Yes, please reinstall with a supported version of Go. Soon, gopls will require at least Go 1.21 (+forward compatibility) to build: golang/go#65917.

I believe the extension should not have tried to install gopls@latest, since it should be knowledgeable of the last supported version. CC @hyangah in case there is a VS Code bug here.

hyangah commented 1 month ago

According to https://github.com/golang/tools/tree/master/gopls#supported-go-versions gopls@v0.14.2 is the last version that can be built with go1.18.

VS Code still claims to support tools installation with go1.18, but that's incorrect. Please manually install gopls. I will update the README page and the error message.

go install golang.org/x/tools/gopls@v0.14.2

findleyr commented 1 month ago

Thanks @hyangah. Transferring to the VS Code issue tracker.

hyangah commented 1 month ago

Duplicate of #3409