This is a creation in Article, where the information may have evolved or changed.
Installing homebrew
In the Homebrew copy installation command, run complete installation in the console
Installing Golnag
$ brew update && brew upgrade$ brew install go
Path configuration
Create a directory as a directory, gopath
create three directories, bin
src
pkg
$ cd ~$ vim .bash_profile
Edit .bash_profile
the file and save it with the following contents
export GOROOT=/usr/local/opt/go/libexec# GOPAT为上面创建的目录路径export GOPATH=/Users/deweixu/coding/Go/go_pathexport PATH=$PATH:$GOROOT/bin:$GOPATH/bin
Run source .bash_profile
to make the configuration PATH
effective.
Installation Complete
Run to go env
view the installation effect:
$ go envGOARCH="amd64"GOBIN=""GOEXE=""GOHOSTARCH="amd64"GOHOSTOS="darwin"GOOS="darwin"GOPATH="/Users/deweixu/coding/Go/go_path"GORACE=""GOROOT="/usr/local/opt/go/libexec"GOTOOLDIR="/usr/local/opt/go/libexec/pkg/tool/darwin_amd64"CC="clang"GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/q3/kxp92gk548z_y9pc1n3qsztw0000gn/T/go-build078494854=/tmp/go-build -gno-record-gcc-switches -fno-common"CXX="clang++"CGO_ENABLED="1"
enjoy golang