diff --git a/eBook/02.3.md b/eBook/02.3.md index cabaf15..c77478a 100644 --- a/eBook/02.3.md +++ b/eBook/02.3.md @@ -44,6 +44,35 @@ cd $GOROOT/src ./all.bash + + **编译注意事项** + + 编译时如果出现如下报错: + + ![](images/2.3.allbasherror.png?raw=true) + + 可能是因为 `$GOROOT_BOOTSTRAP` 变量没有设置。这个目录在安装 Go 1.5 版本及之后的版本时需要设置。 + + 由于在 1.4 版本后,Go 编译器实现了自举,即通过 1.4 版本来编译安装之后版本的编译器。如果不设置该环境变量的话,会产生这样一个错误 `Set $GOROOT_BOOTSTRAP to a working Go tree >= Go 1.4.` 。 + + 设置 `$GOROOT_BOOTSTRAP` 变量: + + export GOROOT_BOOTSTRAP=$HOME/go1.4 + + 设置完成后,下载 1.4 版本的源码到该目录: + + git clone https://github.com/golang/go.git $HOME/go1.4 + git checkout -b release-branch.go1.4 origin/release-branch.go1.4 + + 进入 1.4 的文件夹后,进行编译: + + cd $HOME/go1.4/src + ./make.bash + + 1.4 编译安装好之后,进入 `$GOROOT` 文件夹,真正开始编译安装 Go: + + cd $HOME/go/src + ./all.bash 在完成编译之后(通常在 1 分钟以内,如果你在 B 型树莓派上编译,一般需要 1 个小时),你会在终端看到如下信息被打印: diff --git a/eBook/images/2.3.allbasherror.png b/eBook/images/2.3.allbasherror.png new file mode 100644 index 0000000..4cd79ee Binary files /dev/null and b/eBook/images/2.3.allbasherror.png differ