因為業(yè)務上的需求进副,架構師改了hack了一下golang的源碼,放出一個patch文件,給源碼打了patch之后憎蛤,需要重新編譯go源碼害驹,
我是用brew
安裝的golang, 先用go env
看看
? ~ go env
GOARCH="amd64"
GOBIN="/Users/mac/go/bin"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/mac/go"
GORACE=""
GOROOT="/usr/local/Cellar/go/1.7.5/libexec"
GOTOOLDIR="/usr/local/Cellar/go/1.7.5/libexec/pkg/tool/darwin_amd64"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/w6/jggc8dbd719568_t2lfr2lbh0000gn/T/go-build024499459=/tmp/go-build -gno-record-gcc-switches -fno-common"
CXX="clang++"
CGO_ENABLED="1"
鎖定了源碼的路徑:/usr/local/Cellar/go/1.7.5/libexec
? ~ cd /usr/local/Cellar/go/1.7.5/libexec
? libexec ls
CONTRIBUTING.md PATENTS api doc goid.patch misc robots.txt test
CONTRIBUTORS VERSION bin favicon.ico lib pkg src
? libexec cd src
? src ./all.bash
##### Building Go bootstrap tool.
cmd/dist
ERROR: Cannot find /Users/mac/go1.4/bin/go.
Set $GOROOT_BOOTSTRAP to a working Go tree >= Go 1.4.
Go從1.5版本開始實現(xiàn)“自舉”(Bootstrap)杖刷,也就是用Go來實現(xiàn)Go苹粟、用Go來編譯Go在刺,因此這里的意思是系統(tǒng)默認用go1.4來編譯golang调塌,
但是我的系統(tǒng)里面并沒有go1.4晋南,這里偷個懶
? cp -r /usr/local/Cellar/go/1.7.5/libexec /Users/mac/go1.4
? cd /usr/local/Cellar/go/1.7.5/libexec/src
? src ./all.bash
##### Building Go bootstrap tool.
cmd/dist
##### Building Go toolchain using /Users/mac/go1.4.
bootstrap/internal/sys
bootstrap/compile/internal/big
bootstrap/internal/bio
bootstrap/asm/internal/flags
bootstrap/internal/obj
bootstrap/internal/gcprog
bootstrap/internal/obj/arm
bootstrap/internal/obj/arm64
...
等待編譯測試完成即可。