This is a creation in Article, where the information may have evolved or changed.
Install and use the Go language under Mac OS X (10.7.5)
Reprinted from: http://blog.prosight.me/index.php/2010/08/655, partial modification;
The go language is a new language that Google has introduced to combine dynamic and static language advantages. Here's how to install and use this language under your Mac system.
1. Set Environment variables:
$GOROOT
The root directory of the Go language, usually $home/go, can be any other directory as well.
$GOOS and $GOARCH
Indicates the system and processor type on which the go language resides. $GOOS can be Linux, FreeBSD, Darwin (Mac OS X 10.5 or 10.6) and NaCl (Native Client, an incomplete port). $GOARCH can be AMD64 (64-bit x86, the most mature port), 386 (32-bit x86), ARM (32-bit arm, an incomplete port).
You can set these variables in your shell profile, and I put them in the ~/.bash_profile.
Export goroot= $HOME/goexport goarch=amd64export goos=darwinexport path= $PATH: $GOROOT/bin
Among them, $GOROOT/bin is the directory of the Go default executable file, adding to the path easy to use the various commands of go.
Re-execute
$ source ~/.bash_profile
Make the latest configuration file effective.
2. Get the source file
If you do not have mercurial installed on your system (you cannot use the HG command without installing it), then use this command to install it:
$ sudo easy_install Mercurial
Then use the following command, also get the Go language source file:
$ HG clone-r release https://go.googlecode.com/hg/$GOROOT
3. Install the Go language
$ cd $GOROOT/src$./all.bash
If everything is OK, you should be able to see similar results at the end:
All TESTS PASSED---installed Go for darwin/amd64 in/users/username/goinstalled commands In/usr/local/bin
4. Run Go
Compose the first Hello,world:
Package Mainimport "FMT" Func Main () { fmt. Printf ("Hello, world\n")}
Run:
$ go Run hello.go
5. Update
Go is a developing language and its version is updated frequently, and you can use the following commands to keep the go language the latest version
$ cd $GOROOT/src$ HG pull$ Hg update release$./all.bash
6, Go's official website is: http://golang.org