简体   繁体   中英

GO env variable PATH got messed up

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!

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM