我还应该声明 GOPATH 吗?

should I still declare GOPATH?

作者:

it’s a good idea to explicitly define GOPATH and to put the $GOPATH/bin directory in your executable path. Explicitly defining GOPATH makes it clear where your Go workspace is located and adding $GOPATH/bin to your executable path makes it easier to run third-party tools installed via go install.

谢谢

[S]hould I still declare GOPATH, GOROOT?

否且否!

GOPATH 默认为 $HOME/go,这很好,并且基于 GOPATH 的构建已被弃用 。使用模块。

GOROOT 从来都不是 Go 最终用户的事情。如果您使用 Go 编译器本身或将 Go 安装在不寻常的位置(最终用户不应该这样做),则必须进行设置。

远离任何宣传 GOPATH 甚至建议搞乱 GOROOT 的资源。