英文:
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 <something>
, then that ends up in ~/go/bin/<something>
. 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
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论