[Tips] – How to setup Golang env in MacOSX using homebrew?

Following the steps. If you are checking issues regards some error with your GOROOT may it will solve your problem.

  • Add the ENV VAR’s in your bash_profile as follows. (vim ~/.bash_profile)
export GOPATH="${HOME}/.go"
export GOROOT="$(brew --prefix golang)/libexec"
export PATH="$PATH:${GOPATH}/bin:${GOROOT}/bin"

 

  • Run  the following command to create the $GOPATH
    $ mkdir "${GOPATH}"
  • Run the following command to create the GitHub dir on it. If all is ok, then this dir should be found in the $GOPATH.
$mkdir -p "${GOPATH}/src/github.com"
  • Now, install the GO
$ brew install go
  • Also, get some GO utilities.
$ go get golang.org/x/tools/cmd/godoc
$ go getgolang.org/x/lint

 

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s