This is a creation in Article, where the information may have evolved or changed.
0. Preparatory work
Now is the end of June 2017, I use MacBook Air to try to install the Go source, reference document is Https://golang.org/doc/install/source.
1. Download the source code
Prepare a clean directory and check out the source code. The official documentation steps are as follows:
$ git clone https://go.googlesource.com/go$ cd go$ git checkout go1.8.3
When I do, there is an error checking out the branch, and there is no remote go1.8.3 this branch.
$ git branch* master$ git checkout go1.8.3note:checking out ' go1.8.3 '. You're in the ' detached HEAD ' state. You can look around, make experimentalchanges and commit them, and you can discard any commits do in thisstate Witho UT impacting any branches by performing another checkout. If you want to create a new branch to retain commits your create, you maydo so (now or later) by Using-b with the checkout Command again. Example:git Checkout-b <new-branch-name>head is now at 352996a381 ... [release-branch.go1.8] go1.8.3$ git branch* (head detached at go1.8.3) master$ git branch-a* (head detached at go1.8.3) Master Remotes/origin/head, Origin/master remotes/origin/dev.cc remotes/origin/dev.garbage remotes/origin/dev.g CFE Remotes/origin/dev.inline remotes/origin/dev.power64 Remotes/origin/dev.ssa remotes/origin/dev.tls remotes/ Origin/dev.typealias Remotes/origin/master remotes/origin/release-branch.go1 remotes/origin/release-branch.go1.1 Remotes/origin/release-branch.go1.2 remotes/origin/release-branch.go1.3 remotes/origin/release-branch.go1.4 remotes/origin/ release-branch.go1.5 remotes/origin/release-branch.go1.6 remotes/origin/release-branch.go1.7 remotes/origin/ release-branch.go1.8 remotes/origin/release-branch.r57 remotes/origin/release-branch.r58 remotes/origin/ Release-branch.r59 Remotes/origin/release-branch.r60
In fact go1.8.3 is a tag, not a branch:
$ git tag -l | grep 1.8go1.8go1.8.1go1.8.2go1.8.3go1.8beta1go1.8beta2go1.8rc1go1.8rc2go1.8rc3
Check out from tag:
$ git checkout -b go1.8.3 go1.8.3Switched to a new branch 'go1.8.3'$ git branch* go1.8.3 master$ lsAUTHORS CONTRIBUTORS PATENTS VERSION doc lib robots.txt testCONTRIBUTING.md LICENSE README.md api favicon.ico misc src$ cat VERSION go1.8.3
Check out 1.8.3 successful, continue with subsequent installation steps.
2. Installation
The official documentation step takes only two steps:
$ cd src$ ./all.bash
After I execute an error, missing go bootstrap tool (Forget go has completed bootstrap, need to install Go1.4 compiler. ):
$ ./all.bash ##### Building Go bootstrap tool.cmd/distERROR: Cannot find /Users/xingyongtao/go1.4/bin/go.Set $GOROOT_BOOTSTRAP to a working Go tree >= Go 1.4.
On this issue, the official document says:
To build a bootstrap tool chain from source, use either the Git branch release-branch.go1.4 or Go1.4-bootstrap-20170531.ta R.gz, which contains the Go 1.4 source code plus accumulated fixes to keep the tools running on newer operating systems. (Go 1.4 is the last distribution in which the tool chain is written in C.) After unpacking the Go 1.4 source, CD to the SRC subdirectory and run Make.bash (or, on Windows, Make.bat).
So I just need to check out the go1.4 branch locally and install the line.
$ git checkout release-branch.go1.4Branch release-branch.go1.4 set up to track remote branch release-branch.go1.4 from origin.Switched to a new branch 'release-branch.go1.4'$ git branch go1.8.3 master* release-branch.go1.4
Installation is smooth and setup environment variable Goroot_bootstrap is finished.
(During a copy of the go directory due to an error, make go1.4 and Goroot not the same directory.) )
Re-executing the ./all.bash
installation 1.8.3, the error of repeating the declaration is caused by switching branch repeated compilation. Clean up and try again:
git clean -xf
Installation complete, verification passed, done.