在执行`go install`命令后,你需要手动更新你的路径吗?

huangapple go评论73阅读模式
英文:

go install - do I need to manually update my path?

问题

我对Go的最新最佳实践有些困惑。

在macOS上安装最新的Go(1.17版本),没有设置GOPATH环境变量,使用go mod,我发现以下路径在我的路径中:

/usr/local/go/bin

当我运行go install <something>时,会出现在~/go/bin/<something>中。那为什么~/go/bin不在我的路径中?我需要手动添加吗?

英文:

I'm a bit confused on what the latest best practice is with Go.

Installing the latest (1.17) Go on macos, with no GOPATH env variable, with go mod, I see the following is in my path

/usr/local/go/bin

When I run go install &lt;something&gt;, then that ends up in ~/go/bin/&lt;something&gt;. So why is ~/go/bin not in my path? Do I have to add it manually?

答案1

得分: 5

是的,你需要手动将~/go/bin添加到你的PATH中。

要这样做,可以在你的shell初始化文件(.bashrc.zshrc等)中添加以下行:

export PATH=$PATH:$HOME/go/bin
英文:

Yes you have to manually add ~/go/bin to your PATH.

To do so, add this line in your shell init file (.bashrc, .zshrc ...):

export PATH=$PATH:$HOME/go/bin

huangapple
  • 本文由 发表于 2021年11月24日 23:30:56
  • 转载请务必保留本文链接:https://go.coder-hub.com/70098792.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定