英文:
Installing a Go package on a Raspberry Pi
问题
我目前正在使用Raspbian操作系统的Raspberry Pi Model B+。我已经安装了Go,并且想要安装scollector。我尝试了以下命令:
$ go get bosun.org/cmd/scollector
但是出现了错误:
package net/http/cookiejar: unrecognized import path "net/http/cookiejar"
我还尝试通过ARMv6二进制文件进行安装。我对该二进制文件运行了chmod +x命令,然后尝试使用./scollector-linux-armv6
执行它,但是出现了一个错误,提示"Text file busy."。
英文:
I am currently using Raspbian on my Raspberry Pi Model B+. I already have Go installed and want to install scollector. I tried
$ go get bosun.org/cmd/scollector
but got the error
package net/http/cookiejar: unrecognized import path "net/http/cookiejar"
I also tried to install via the ARMv6 binary. I ran the chmod +x command on the binary and then tried to execute it using ./scollector-linux-armv6
but got an error saying "Text file busy."
答案1
得分: 3
这是在https://github.com/revel/revel/issues/342上出现的消息:你可能使用的是你发行版附带的旧版本Go,缺少该软件包。你可以从Dave Cheney的网站下载最新的ARMv6版本的Go(我写这篇文章时是1.4.2)。你可能需要解压缩它,将生成的目录移动/重命名为~/go
,并通过添加以下行来更改你的.bashrc
以设置路径和GOPATH:
# 可选的;在你的主目录下创建bin/、pkg/和src/目录供Go使用
export GOPATH=~
# 将'go'工具、编译后的Go二进制文件和其他文件放在~/bin中,并将其添加到PATH中
# 如果不需要,可以删除:~/bin
export PATH=~/go/bin:~/bin/:$PATH
# 告诉Go它不在/usr/local/go中
export GOROOT=~/go
然后执行. ~/bashrc
或注销并重新登录以更新你的环境。你可能会遇到其他问题;如果卡住了,可以将这些问题作为附加问题发布,并提供尽可能多的细节以及对这个问题的引用。如果你使用其他shell,bash
特定的细节可能会有所不同。
你也可以(正如用户allonhadaya指出的)进行交叉编译:从台式机或笔记本电脑构建二进制文件,然后将其传输到你的树莓派上。像goxc这样的工具可以帮助管理这个过程(如果你愿意,也可以使用环境变量如GOOS
和GOARCH
手动完成)。在Go 1.5中,预计将在2015年底发布,这将变得更简单。
在chmod
之后出现“Text file busy”显然是某种情况发生了。在chmod和运行二进制文件之间运行sync
可能会有所帮助。如果文件仍在下载中,也可能发生这种情况。无论如何,拥有一个Go环境对于你想构建的其他项目或者你自己想做的任何编码都是有用的。
祝你好运!
英文:
This message came up at https://github.com/revel/revel/issues/342: you likely have the old version of Go that came with your distribution and it lacks that package. You can download a recent go (1.4.2 as I'm writing) for ARMv6 from Dave Cheney's site. You'll probably want to unpack that, move/rename the resulting dir to ~/go
, and change your .bashrc
to set up a PATH and GOPATH in your homedir by adding lines like:
# optional; makes bin/, pkg/ and src/ under your homedir for Go
export GOPATH=~
# puts the 'go' tool + built go binaries + anything else in ~/bin in PATH
# remove the :~/bin bit if you don't want it
export PATH=~/go/bin:~/bin/:$PATH
# lets Go know that it's not in /usr/local/go
export GOROOT=~/go
then . ~/bashrc
or log out and in to put the latest in your environment. You might then run into other problems; if you get stuck, maybe post those as additional questions with all the details you can and a reference to this question. And bash
-specific details vary if you use another shell.
You can also (as user allonhadaya points out) cross-compile: build binaries to be transferred to your Raspberry Pi from a desktop or laptop. Tools like goxc help manage this (you can also do it by hand with environment variables like GOOS
and GOARCH
if you want). In Go 1.5, scheduled to come out at the end of 2015, it will get simpler.
"Text file busy" right after chmod
is apparently something that happens. Running sync
between the chmod and running the binary may help. It could plausibly happen if the file were still downloading, too. Either way, it's still useful to have a Go environment for any other projects you want to build or potentially any coding you want to do yourself.
Good luck with what you're doing!
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论