This is a creation in Article, where the information may have evolved or changed.
Install Go1.6 from source code to CentOS 7 in China network environment
Https://github.com/northbright/Notes/blob/master/Golang/china/install-go1.6-from-source-on-centos7-in-china.md
Background
- In the current Chinese network environment, we are unable to access Google's services, including golang.org.
- Downloading a precompiled binary go release from a third-party website may present a risk of third-party source code injection, such as previous xcodeghost.
GoThe authoritative warehouse address is https://go.googlesource.com/go, and there is also a mirrored warehouse in Https://github.com/golang/go.
- At least for now, we have access to GitHub:-)
Problem
- The Go1.6 compilation process requires the Go1.4 of the two in the implementation of Bootstrap (bootstrap) (simply: go requires go itself to compile).
Solution Solutions
- Get the source code for go from GitHub's Go warehouse image.
- First compile the Go1.4 (only need
gcc and glibc-devel , do not need go to compile).
- Compile the Go1.6 using a compiled Go1.4 binary file.
Steps
If you have previously installed the old version of Go, clear the $GOPATH, $GOROOT variable.
Install Git.
- Configuration
Git
git config --global user.email "email-for-github"
git config --global user.name "user name"
- Create SSH key and add public key to your GitHub account.
ssh-keygen -t rsa -b 2048
- Copy
~/.ssh/id_rsa.pub the public key to GitHub SSH settings to add a new SSH key
Installation gcc andglibc-devel
sudo yum install gcc glibc-devel
Compiling from source code install Go1.4
cd ~/
git clone git@github.com:golang/go.git
cd go
git checkout -b 1.4.3 go1.4.3
cd src
./all.bash
Copy ~/go to $GOROOT_BOOTSTRAP (default value is ~/go1.4 )
Compiling from source code install Go1.6
cd ~/go
git clean -dfx
git checkout -b 1.6 go1.6
cd src
./all.bash
Set up $GOPATH and add go binary path to$PATH
Restart and test