This is a creation in Article, where the information may have evolved or changed.
1, environment variable settings
~$ CD
~$ mkdir Go
~$ mkdir Bin
~$ sudo gedit. BASHRC
At the end of the bash file, add the following code to set the directory variable:
Export goroot= $HOME/go
Export Goos=linux
Export goarch=386
Export gobin= $HOME/bin
Save File
~$ source. BASHRC
~$ sudo gedit/etc/profile
At the end of the file modification Path,path does not exist, add the following statement directly, otherwise add
Export path= $HOME/bin: $PATH
Save File
~$ Source/etc/profile
Perform env | grep ' ^go ' tests whether the GO environment variable has been set correctly
2. Get Resources
~$ Hg clone-r release https://go.googlecode.com/hg/$GOROOT
If it is not successful, install mercurial first:
~$ sudo apt-get install mercurial
3, installation
~$ sudo apt-get install bison gcc Libc6-dev ed
~$ CD $GOROOT/src
~$ ./all.bash
Wait a few minutes and finally it will Self-test---CD. /test
~$ CD
~$ mkdir Hellogo
~$ CD Hellogo
~$ Cat >hello.go <<eof
>Package Main
>Import "FMT"
>Func Main () {
>Fmt. Printf ("Hello, world/n"
> }
> Eof
~$ 8g Hello.go
~$ 8l hello.8
~$ ./8.out
Hello, world
4, reference
1,golang official website http://golang.org/
Original address: http://blog.csdn.net/xinshg/article/details/5199651