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