1. 安裝go
手動(dòng)方式
官網(wǎng)下載壓縮包,然后配置GOROOT和PATH,筆者采用下邊這種方式。
Homebrew方式
筆者在 macOS Catalina 版本0.15.1 (19B88)
下直接安裝遇到點(diǎn)問題,如下:
// 考慮使用 install 直接搞定,結(jié)果各種超時(shí)
$ brew install go
Error: Net::OpenTimeout
// 參考 http://mirrors.ustc.edu.cn/help/homebrew-bottles.html 更換源,結(jié)果報(bào)錯(cuò)
$ brew install go
··· ···
Error: Xcode alone is not sufficient on Dunno.
Install the Command Line Tools:
xcode-select --install
// 安裝xcode-select,反饋已經(jīng)安裝
$ xcode-select --install
xcode-select: error: command line tools are already installed, use "Software Update" to install updates
// 嘗試升級(jí)xcode-select,發(fā)現(xiàn)無(wú)需升級(jí)
$ softwareupdate --list
Software Update Tool
Finding available software
No new software available.
$ softwareupdate -i Command Line Tools
Software Update Tool
Command: No such update
Line: No such update
Tools: No such update
No updates are available.
// 最后懷疑brew版本問題,發(fā)現(xiàn)確實(shí)版本過(guò)低
$ brew --version
Homebrew 1.7.1
Homebrew/homebrew-core (git revision b0f2e; last commit 2019-11-17)
// 重新安裝新版本
$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
$ brew --version
Homebrew 2.1.16
Homebrew/homebrew-core (git revision b0f2e; last commit 2019-11-17)
Homebrew/homebrew-cask (no git repository)
// 再次安裝,終于ok了
$ brew install go
==> Downloading https://mirrors.ustc.edu.cn/homebrew-bottles/bottles/go-1.13.4.catalina.bottle.tar.gz
######################################################################## 100.0%
==> Pouring go-1.13.4.catalina.bottle.tar.gz
?? /usr/local/Cellar/go/1.13.4: 9,271 files, 414MB
$ go version
go version go1.13.4 darwin/amd64