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

ghj1976 · · 9911 次点击 · · 开始浏览    
这是一个创建于 的文章,其中的信息可能已经有所发展或是发生改变。

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

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 文件。


有疑问加站长微信联系(非本文作者)

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

9911 次点击  
加入收藏 微博
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传