environment variables - What is GOPATH actually supposed to be with multiple Go versions installed? - Stack Overflow

I am using Linux (Debian 12) and have the latest version of Go installed, along with Go v1.20.6 (via th

I am using Linux (Debian 12) and have the latest version of Go installed, along with Go v1.20.6 (via the Managing Multiple Installations method).

When running go1.20.6, I get the following variable values (where [user] is the current username logged into the system) when running go1.20.6 env:

GO111MODULE="auto"
GOBIN=""
GOPATH="/home/[user]/go"
GOROOT="/home/[user]/sdk/go1.20.6"
GOTOOLDIR="/home/[user]/sdk/go1.20.6/pkg/tool/linux_amd64"
GOVERSION="go1.20.6"

Under one of the official "How to Write Go Code" document, it states:

The install directory is controlled by the GOPATH and GOBIN environment variables. If GOBIN is set, binaries are installed to that directory. If GOPATH is set, binaries are installed to the bin subdirectory of the first directory in the GOPATH list. Otherwise, binaries are installed to the bin subdirectory of the default GOPATH ($HOME/go or %USERPROFILE%\go).

So, if I'm using multiple installations of Go, shouldn't GOPATH be set to something like the following instead of pointing to the primary Go installation on my machine?

GOPATH="/home/[user]/sdk/go1.20.6"

This is due to needing an earlier version of gopls, according to my IDE. I could probably ignore the warning, but there is a ./bin folder in the ~/sdk/go1.20.6 folder with go and gofmt indicating that it uses those executables, so shouldn't the correct version of gopls for my go version drop into ~/sdk/go1.20.6/bin, too?

(Yes, there are some IDE-specific settings I can tweak, but they are limited and this is just a general question.)

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744301892a4567541.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信