This is a creation in Article, where the information may have evolved or changed.
Installation
To build Go 1.x (x≥5), you need to first install Go 1.4 $GOROOT_BOOTSTRAP . The default $GOROOT_BOOTSTRAP is $HOME/go1.4 . We use Go 1.4 as the base version of the boot to compile the toolchain.
Install go1.4 First, then install go1.6.2 or other versions.
Preset go1.4
Download go1.4.linux-amd64.tar.gz or other correspondence package, this is already compiled well, larger, directly there is a bin file available
Unzip the package, modify the directory name go->go1.4
Move to $HOME/ next, there will be a path after the installation is complete /root/go1.4/bin
Install new version
Add the environment variable, ~/.BASHRC, and add the following variable:
export GOROOT=$HOME/goexport PATH=$GOROOT/bin:$PATH
Run environment variables:
source ~/.bashrc
$HOMEPath is /root
Installing the Go tool chain
sudo apt-get install bison ed gawk gcc libc6-dev make git
Installing mercurial
sudo apt-get install mercurial
Download go source extract to the $GOROOT directory
I downloaded it from here, and I can get it from other places.
http://www.golangtc.com/download
Compiling go source code
cd$GOROOT/src./all.bash
If the installation is successful, the following information is displayed:
##### ../test##### API checkversionis"go1.6.2"ignoring -next /root/go/api/next.txtALL TESTS PASSED---forinin /root/go/bin
Test
To create a file a.go :
package mainimport( "fmt")func main(){ fmt.Println("hello world")}
Execute command:
go run a.go
Reference
Http://www.cnblogs.com/ztiandan/archive/2012/12/08/2808295.html
Http://www.cnblogs.com/ztiandan/archive/2012/12/08/2808856.html