直入主题,环境Mac os Mojave 10.14.6
配置环境变量
shell
export GOROOT=$HOME/Development/go
export GOPATH=$HOME/Development/path
export PATH=$PATH:$HOME/Development/go/bin:/$HOME/Development/path/bin
#建议直接设置为go1.4,后续会创建go1.4目录,由于之前编译一直设置的go,走了很多弯路。
export GOROOT_BOOTSTRAP=$HOME/Development/go1.4编译
shell
git clone https://github.com/golang/go.git
cd go/src
./all.bash报错如下
shell
Set $GOROOT_BOOTSTRAP to a working Go tree >= Go 1.4.根据github提示执行
shell
#从源代码构建Go1.4
git checkout -b 1.4.3 go1.4.3
cd src
./all.bash
#复制~/go到$GOROOT_BOOTSTRAP(~/go1.4默认情况下)`
cp ~/go ~/go1.4 -rf
#从源代码构建Go1.6
cd ~/go
git clean -dfx
git checkout -b 1.6 go1.6
cd src
./all.bash报错如下
shell
missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun安装
shell
xcode-select --install再次编译
shell
./all.bash报错如下
shell
Building Go cmd/dist using /Users/zhangzhichao/Development/go1.4.
Building Go toolchain1 using /Users/zhangzhichao/Development/go1.4.
Building Go bootstrap cmd/go (go_bootstrap) using Go toolchain1.
/Users/zhangzhichao/Development/go/src/runtime/zruntime_defs_darwin_amd64.go:7:7: _Gidle redeclared in this block
previous declaration at /Users/zhangzhichao/Development/go/src/runtime/runtime2.go:35:11
/Users/zhangzhichao/Development/go/src/runtime/zruntime_defs_darwin_amd64.go:8:7: _Grunnable redeclared in this block
previous declaration at /Users/zhangzhichao/Development/go/src/runtime/runtime2.go:39:2
/Users/zhangzhichao/Development/go/src/runtime/zruntime_defs_darwin_amd64.go:9:7: _Grunning redeclared in this block
previous declaration at /Users/zhangzhichao/Development/go/src/runtime/runtime2.go:44:2
/Users/zhangzhichao/Development/go/src/runtime/zruntime_defs_darwin_amd64.go:10:7: _Gsyscall redeclared in this block
previous declaration at /Users/zhangzhichao/Development/go/src/runtime/runtime2.go:49:2
/Users/zhangzhichao/Development/go/src/runtime/zruntime_defs_darwin_amd64.go:11:7: _Gwaiting redeclared in this block再次编译
git clean -df最终编译完成
shell
##### ../misc/cgo/testcshared
SKIP - short mode and $GO_BUILDER_NAME not set
##### ../misc/cgo/testplugin
ok misc/cgo/testplugin 0.008s
##### ../misc/cgo/errors
PASS
##### ../test/bench/go1
##### ../test
##### API check
Go version is "go1.13rc1", ignoring -next /Users/zhangzhichao/Development/go/api/next.txt
ALL TESTS PASSED
---
Installed Go for darwin/amd64 in /Users/zhangzhichao/Development/go
Installed commands in /Users/zhangzhichao/Development/go/bin
peakchao