admin管理员组

文章数量:1402485

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.)

本文标签: