golang 源码编译安装
在version<=1.4,golang的所有组件都是用c+asm写的,之后的版本是用go+asm写的,所以安装早期的版本只需要gcc即可,但是后期版本的安装需要依赖早期的版本,下面分别从1.4版本和1.8.3两个版本分别介绍其源码安装过程
1.4版本
cd ~/package
wget https://storage.googleapis.com/golang/go1.4-bootstrap-20170531.tar.gz
tar zxvf go1.4-bootstrap-20170531.tar.gz go1.4
cd go1.4/src/
CGO_ENABLED=0 ./all.bash若只想使用1.4版本,此时可以在~/.bash_profile中添加export PATH=$PATH:~/package/go1.4/bin
1.8.3版本
cd ~/package
wget https://github.com/golang/go/archive/go1.8.3.tar.gz
tar zxvf go1.8.3.tar.gz go1.8.3
export GOROOT_BOOTSTRAP=~/package/go1.4
cd go1.8.3/src
./all.bash若想用1.8.3版本,可以把~/bash.profile文件中的go1.4改成go1.8.3即可