Golang是Google開發的一種編譯型,平行化編程語言。具備簡潔、快速、安全。善於內存管理、數組安全,而且編譯迅速
Go語言設計支持主流的32位和64位的x86平臺,同時也支持32位的ARM架構。Go語言在Go1版本上支持Windows, 蘋果Mac OS X, Linux和FreeBSD操做系統。html
固然,一切語言的學習都從搭建環境開始(macOS)golang
Homebrew 安裝參考:http://brew.sh/shell
$ brew install go
==> Downloading https://homebrew.bintray.com/bottles/go-1.10.3.high_sierra.bottl Already downloaded: /Users/faremax/Library/Caches/Homebrew/go-1.10.3.high_sierra.bottle.tar.gz ==> Pouring go-1.10.3.high_sierra.bottle.tar.gz ==> Caveats A valid GOPATH is required to use the `go get` command. If $GOPATH is not specified, $HOME/go will be used by default: https://golang.org/doc/code.html#GOPATH You may wish to add the GOROOT-based install location to your PATH: export PATH=$PATH:/usr/local/opt/go/libexec/bin ==> Summary ? /usr/local/Cellar/go/1.10.3: 8,170 files, 336.7MB
安裝成功後須要配置一下環境變量,在~/.bash_profile
中添加如下內容:編程
#golang export GOPATH=$HOME/go export GOBIN=$GOPATH/bin export PATH=$PATH:$GOBIN
這裏能夠看出須要設置GOPATH和GOBIN的環境變量,以及設置PATH.數組
爲使修改馬上生效,執行:安全
$ source .bash_profile
查看配置是否生效:bash
$ go env
獲得以下內容:架構
GOARCH="amd64" GOBIN="/Users/faremax/go/bin" GOCACHE="/Users/faremax/Library/Caches/go-build" GOEXE="" GOHOSTARCH="amd64" GOHOSTOS="darwin" GOOS="darwin" GOPATH="/Users/faremax/go" GORACE="" GOROOT="/usr/local/Cellar/go/1.10.3/libexec" GOTMPDIR="" GOTOOLDIR="/usr/local/Cellar/go/1.10.3/libexec/pkg/tool/darwin_amd64" GCCGO="gccgo" CC="clang" CXX="clang++" CGO_ENABLED="1" CGO_CFLAGS="-g -O2" CGO_CPPFLAGS="" CGO_CXXFLAGS="-g -O2"GOARCH="amd64" GOBIN="/Users/faremax/go/bin" GOCACHE="/Users/faremax/Library/Caches/go-build" GOEXE="" GOHOSTARCH="amd64" GOHOSTOS="darwin" GOOS="darwin" GOPATH="/Users/faremax/go" GORACE="" GOROOT="/usr/local/Cellar/go/1.10.3/libexec" GOTMPDIR="" GOTOOLDIR="/usr/local/Cellar/go/1.10.3/libexec/pkg/tool/darwin_amd64" GCCGO="gccgo" CC="clang" CXX="clang++" CGO_ENABLED="1" CGO_CFLAGS="-g -O2" CGO_CPPFLAGS="" CGO_CXXFLAGS="-g -O2" CGO_FFLAGS="-g -O2" CGO_LDFLAGS="-g -O2" PKG_CONFIG="pkg-config" GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/f0/wl0qf7mn1131dc3brmbb3_d00000gn/T/go-build994213970=/tmp/go-build -gno-record-gcc-switches -fno-common" CGO_FFLAGS="-g -O2" CGO_LDFLAGS="-g -O2" PKG_CONFIG="pkg-config" GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/f0/wl0qf7mn1131dc3brmbb3_d00000gn/T/go-build994213970=/tmp/go-build -gno-record-gcc-switches -fno-common"
能夠看到,配置生效,環境變量設置完成!編程語言