go install runtime/cgo: open /usr/local/go/pkg/darwin_amd64/runtime/cgo.a: permission denied

在做更新时,收到下面提示:

go get  github.com/astaxie/beego
go install runtime/cgo: open /usr/local/go/pkg/darwin_amd64/runtime/cgo.a: permission denied

看目录下,也没有cgo.a 文件。

image

 

所以是找不到这个文件报的错误,而不是没有权限的问题。通过sudo来设置权限是不能解决这个问题的。

http://www.cnblogs.com/ghj1976/archive/2013/05/17/3084006.html
http://grokbase.com/p/gg/golang-china/135gh2bj5p/gocn-9214-%E5%8D%87%E7%BA%A7%E5%88%B0go1-1%E5%90%8E%EF%BC%8C-go-get-u-%E6%97%A0%E6%B3%95%E6%9B%B4%E6%96%B0%EF%BC%8C%E7%AB%9F%E7%84%B6%E6%8F%90%E7%A4%BA-cannot-download-gopath-not-set

 

解决方法:

禁用CGO

export CGO_ENABLED=0

然后再执行go get 命令。

原因:

It's a problem with your Go installation. Similar issues are reported there and there. I may only add that on Mac version from Homebrew works just fine.

参考: https://github.com/AlekSi/nut/issues/26

交叉编译时,会丢掉cgo.a 文件。

你可能感兴趣的:(Permission)