英文:
Go 1.6 does not work on OS X Yosemite
问题
你好!以下是翻译好的内容:
使用了所有补丁的OS X Yosemite。安装了go,命令如下:
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: 无法识别的导入路径 "archive/zip"(导入路径不以主机名开头)
package bytes: 无法识别的导入路径 "bytes"(导入路径不以主机名开头)
package encoding/json: 无法识别的导入路径 "encoding/json"(导入路径不以主机名开头)
package encoding/xml: 无法识别的导入路径 "encoding/xml"(导入路径不以主机名开头)
package errors: 无法识别的导入路径 "errors"(导入路径不以主机名开头)
package expvar: 无法识别的导入路径 "expvar"(导入路径不以主机名开头)
package flag: 无法识别的导入路径 "flag"(导入路径不以主机名开头)
package fmt: 无法识别的导入路径 "fmt"(导入路径不以主机名开头)
...
Go支持OS X 10.10吗?我在这里漏掉了什么?
英文:
OS X Yosemite with all patches. Installed go with
brew install go --cross-compile-common
Created ~/work, setup environments like this:
export GOPATH=$HOME/work
export GOROOT='/usr/local/Cellar/go/1.6'
export PATH=$PATH:$GOROOT/bin
Now attempt to add a package gives me an error:
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)
...
Does Go support OS X 10.10?
What did I miss here?
答案1
得分: 6
尝试将你的GOROOT
设置为/usr/local/Cellar/go/1.6/libexec
。我记得我曾经遇到过同样的问题,这个方法解决了它。
英文:
Try to set your GOROOT
to /usr/local/Cellar/go/1.6/libexec
. I remember I had the same problem and this fixed it.
答案2
得分: 4
你不再需要设置GOROOT
变量了。
英文:
You don't need to set the GOROOT
variable anymore http://dave.cheney.net/2013/06/14/you-dont-need-to-set-goroot-really
答案3
得分: 2
Go语言支持OS X 10.10吗?
是的,对于Go 1.12及以下版本是支持的。
从2019年第四季度开始,不再支持。请参考Go 1.12文档:
Darwin
Go 1.12是最后一个可以在macOS 10.10 Yosemite上运行的版本。
Go 1.13 (2019年第四季度)将需要macOS 10.11 El Capitan或更高版本。
在Darwin上进行系统调用时,现在使用libSystem
,以确保与未来版本的macOS和iOS向前兼容。切换到libSystem
触发了对私有API使用的额外App Store检查。由于被视为私有API,在iOS上,syscall.Getdirentries
现在总是返回ENOSYS
错误。
英文:
> Does Go support OS X 10.10?
Yes, for Go up to 1.12.
Starting Q4 2019, not anymore. See 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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论