Go 1.6 不适用于 OS X Yosemite

Go 1.6 does not work on OS X Yosemite

OS X Yosemite 所有补丁。已安装

brew install go --cross-compile-common

已创建 ~/work,设置环境如下:

export GOPATH=$HOME/work
export GOROOT='/usr/local/Cellar/go/1.6'
export PATH=$PATH:$GOROOT/bin

现在尝试添加包时出现错误:

go get golang.org/x/tools/cmd/godoc

package archive/zip: unrecognized import path "archive/zip" (import path does not begin with hostname)
package bytes: unrecognized import path "bytes" (import path does not begin with hostname)
package encoding/json: unrecognized import path "encoding/json" (import path does not begin with hostname)
package encoding/xml: unrecognized import path "encoding/xml" (import path does not begin with hostname)
package errors: unrecognized import path "errors" (import path does not begin with hostname)
package expvar: unrecognized import path "expvar" (import path does not begin with hostname)
package flag: unrecognized import path "flag" (import path does not begin with hostname)
package fmt: unrecognized import path "fmt" (import path does not begin with hostname)
...

Go 支持 OS X 10.10 吗? 我在这里错过了什么?

尝试将 GOROOT 设置为 /usr/local/Cellar/go/1.6/libexec。我记得我遇到过同样的问题,这解决了它。

您不再需要设置 GOROOT 变量 http://dave.cheney.net/2013/06/14/you-dont-need-to-set-goroot-really

Does Go support OS X 10.10?

是的,升级到 1.12。
从 2019 年第四季度开始,不再是。见 Go 1.12 doc:

Darwin

Go 1.12 is the last release that will run on macOS 10.10 Yosemite.

Go 1.13 (Q4 2019) will require macOS 10.11 El Capitan or later.

libSystem is now used when making syscalls on Darwin, ensuring forward-compatibility with future versions of macOS and iOS.
The switch to libSystem triggered additional App Store checks for private API usage.
Since it is considered private, syscall.Getdirentries now always fails with ENOSYS on iOS.