英文:
GO env variable PATH got messed up
问题
我正在尝试使用以下命令使用go安装软件包:
go install fyne.io/fyne/v2/cmd/fyne@latest
这与指令中所说的一样,但理想情况下应该返回以下消息:
Users/name/go/bin/fyne
但是,当我输入该命令时,出现以下问题:
fyne未找到
软件包作者告诉我,您可能没有将GOBIN路径添加到PATH变量中。我怀疑这是golang/go#39531问题。
当我在命令行中执行导出命令时:
export
我得到了以下Golang路径:
PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/go/bin
我认为上述路径可能出错了,因为我已经多次安装和卸载,并使用以下命令进行卸载:
我已经通过以下方式卸载:
$ sudo rm -rf /usr/local/go
$ sudo rm /etc/paths.d/go
尽管我尝试通过以下方式更改:
vim ~/.zshrc
添加一行:
export PATH=$PATH:$(go env GOPATH)/bin
但仍然不起作用。
解决添加GOBIN到路径的最佳方法是什么?
谢谢!
英文:
I am trying to install package using go with below command:
go install fyne.io/fyne/v2/cmd/fyne@latest
This is the same as what the instruction said but ideally it should return below message
Users/name/go/bin/fyne
But when I enter the command it has below issue
fyne not found
The package author told me You likely don’t have the GOBIN path added to your PATH variable. I suspect it is golang/go#39531 that comes back to bite you.
When I execute export in the command line:
export
I am getting the below Golang path:
PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/go/bin
I thought the path above was messed up because I have done multiple times of installing and uninstalling with uninstalling using below commands
I've done uninstall via:
$ sudo rm -rf /usr/local/go
$ sudo rm /etc/paths.d/go
Althought I've tried to change via:
vim ~/.zshrc
Add a line
export PATH=$PATH:$(go env GOPATH)/bin
It's still not working.
What’s the best approach to resolve adding GOBIN to path?
Thanks!
答案1
得分: 1
如果你只需要将GOBIN
添加到PATH
中,可以执行以下操作:
PATH=$PATH:$(go env GOBIN)
由于GOBIN
通常是~/go/bin
,你通常可以只执行以下操作:
PATH=$PATH:~/go/bin
你可以将该命令添加到~/.zshrc
中,以使其持久化,并立即执行它:
source ~/.zshrc
之后,如果你的shell仍然无法找到fyne
,请检查当前PATH
的内容是否包含GOBIN
:
echo $PATH
如果没有包含,说明在将GOBIN
添加到PATH
时出现了问题。
英文:
If all you need is to add GOBIN
to PATH
, do:
PATH=$PATH:$(go env GOBIN)
Since GOBIN
often is ~/go/bin
, you usually could get away with just:
PATH=$PATH:~/go/bin
You can add that command to ~/.zshrc
to make it persistent and then source it to execute it immediately:
source ~/.zshrc
After that, if your shell remains unable to find fyne
, check that current PATH
content includes GOBIN
with:
echo $PATH
If it doesn't, something went wrong when adding GOBIN
to PATH
.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论