因為要使用 mercurial 來下載 src,先到 http://dag.wieers.com/rpm/packages/mercurial/ 下載 rpm:
$ wget http://dag.wieers.com/rpm/packages/mercurial/mercurial-0.9.5-1.el5.rf.i386.rpm
$ rpm -ivh mercurial-0.9.5-1.el5.rf.i386.rpm
再來就是下載 repository,我設定的位置是 /root/go:
$ hg clone -r release https://go.googlecode.com/hg/ /root/go
設定環境變數:
$ export GOROOT=/root/go
$ export GOBIN=/root/bin
$ export GOOS=linux
$ export GOARCH=386
$ export PATH=$PATH:/root/bin
編譯 GO 編譯器:
$ cd /root/go/src
$ ./all.bash
寫一個 Hellow World:
$ cat >hello.go <<EOF
package main
import "fmt"
func main() {
fmt.Printf("hello, worldn")
}
EOF
$ 6g hello.go
$ 6l hello.6
$ ./6.out