Installing golang using Homebrew
golang using Homebrew as follows:
$ brew install golang
This will install to the following location:
$ which go /usr/local/bin/go
golang binary distributions expect to be installed to the standard location of
/usr/local/go. This will not be the case, as Homebrew installs into
/usr/local/bin/go, so we need to manually set the
GOROOT environment variable to point the correct location as follows:
See https://golang.org/doc/install#tarball_non_standard for more information on
First set a
DEVELOPMENT_HOME environment variable. This will point to the top-level directory under which all code artefacts will exist, regardless of language.
Next, set the
GOPATH environment variable. This will point to the root directory where all
golang-related artefacts will exist. Make this a direct subdirectory of the
See https://golang.org/cmd/go/#hdr-GOPATH_environment_variable for information on
Test the Installation
$ go get github.com/golang/example/hello $ ls $GOPATH/src/github.com/golang/example/hello hello.go $ ls $GOPATH/bin/hello -rwxr-xr-x 1 paul staff 1603584 9 Dec 18:03 hello $ $GOPATH/bin/hello Hello, Go examples!
See https://golang.org/doc/code.html#remote for more information.