Before it happened, what I am doing is trying to use the dep to manage my golang code dependency.
What I found right now is I cannot do any command with go, even if I try to uninstall it with brew by brew uninstall go and do brew install go again.
If I am doing a go env it will show like this:
$ go env
go: cannot find GOROOT directory: /usr/local/cellar/go/1.13.1/libexec
$ ls /usr/local/Cellar/go/1.13.8/libexec/
CONTRIBUTING.md SECURITY.md bin lib robots.txt
CONTRIBUTORS VERSION doc misc src
PATENTS api favicon.ico pkg test
$ go version
go: cannot find GOROOT directory: /usr/local/cellar/go/1.13.1/libexec
$ go build
go: cannot find GOROOT directory: /usr/local/cellar/go/1.13.1/libexec
$ echo $GOPATH
/Users/mymac/go
$ echo $GOROOT
$
What should I do and check?
I personally use this for Homebrew
export GOPATH=$HOME/go
export GOBIN=$GOPATH/bin
# Homebrew
export GOROOT="$(brew --prefix golang)/libexec"
# Manual install
# export GOROOT=/usr/local/go
export PATH=$PATH:$GOPATH/bin
export PATH=$PATH:$GOROOT/bin
Blogpost
Try this:
https://gist.github.com/vsouza/77e6b20520d07652ed7d
# Set variables in .bashrc file # don't forget to change your path correctly! export GOPATH=$HOME/golang export GOROOT=/usr/local/opt/go/libexec export PATH=$PATH:$GOPATH/bin export PATH=$PATH:$GOROOT/bin
Of course, you'll need to change "$HOME/golang" and "/usr/local/opt/go: to your actual path names.
From OP:
finally i solve this, can you help to update your comment then i will set it as SOLVED.
i use
export GOROOT=/usr/local/Cellar/go/1.13.8/libexec/instead of
GOROOT=/usr/local/opt/go/libexec
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With