golang環境安裝問題集錦

直入主題,環境Mac os Mojave 10.14.6

配置環境變量
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
編譯
git clone https://github.com/golang/go.git 
cd go/src
./all.bash

報錯如下

Set $GOROOT_BOOTSTRAP to a working Go tree >= Go 1.4.
根據github提示執行
#從源代碼構建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

報錯如下

missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
安裝
xcode-select --install
再次編譯
./all.bash

報錯如下

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

最終編譯完成

##### ../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

go新版本會依賴go1.4版本構建,走了好多彎路,之前不停的切換分支修改環境變量,後來突然想通,需要同時擁有兩個版本。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章