This is a creation in Article, where the information may have evolved or changed.
Original address: http://www.the5fire.com/setup-golang-env-on-mac.html
Installation is relatively easy, a brief introduction, after more experience in the dry.
1. Installation for all platform official website has installation instructions, here only for Mac system, download the latest version of the download page, download the direct installation can
2. Set the environment variable configuration goroot and gopath:
To create a home directory Go folder: mkdir ~/go The following things put to. BASH_RC (or maybe. bash_profile or. zshrc) export Goroot=/usr/share/goexport gopath= $HOME/ Goexport path= $PATH: $GOROOT/bin
- Try it.
To create a new Hello.go file:
Package Mainimport "FMT" Func Main () { fmt. Printf ("Hello, world\n")}
Run: Go run hello
- Install additional Packages
Try go get xxxx on the line, such as I want to install MongoDB driver:
Go get Labix.org/v2/mgo
If you do not have BZR installed, you must first install BZR:
Brew install BZR or download https://launchpad.net/bzr/2.5/2.5.1/+download/bzr-2.5.1.tar.gz to this, unzip the CD to the directory after completion. setup.py Install
Other packages are also available with the Get command, which can be installed directly from GitHub
- Configure VIM
Refer to this article: http://wenzhang.baidu.com/share/article/view?key=a534d1ed8359f3dd-1381909112&uk=1880012816
Okay, let ' s go!.