英文:
go - Instructions for installing from the ubuntu ppa
问题
我已经使用Go语言ppa为Ubuntu安装了golang-stable。
官方安装说明似乎忽略了这个选项,并且没有提到它。
我的问题是:有人知道在使用sudo apt-get
安装这个软件包之后是否还需要其他操作吗?特别是,我是否需要手动设置任何环境变量?
我问这个问题是因为我能够“go get
”Go-SDL,但是当我尝试执行它的测试时,我得到以下错误:
$ ./test
panic: No such environment variable: GOPATH
这有点让我困惑。那个变量不应该已经初始化了吗?特别是考虑到我已经能够编译和安装一个库。
英文:
I've installed golang-stable using the Go Language ppa for Ubuntu.
The Official Installation Instructions seem to ignore this option, and don't mention it at all.
My question is: does anyone know if anything else is needed after doing the sudo apt-get
for this package? In particular, do I have to manually set any environment variables?
I'm asking because I've been able to "go get
" Go-SDL, but when I try to execute its test I get the following error:
$ ./test
panic: No such environment variable: GOPATH
This kind of confuses me. Shouldn't that variable be initialized already? Especially given that I have been able to compile and install a library.
答案1
得分: 5
你在/usr/lib/go/bin/
安装的go
命令内部包含一个默认路径,如果环境变量GOPATH
不存在,则使用该默认路径。在Ubuntu软件包的情况下,该默认路径指向/usr/lib/go
。因此,Go-SDL的安装目录位于/usr/lib/go/src
的某个位置。以这种方式安装Go-SDL需要root权限。
我建议您按照http://golang.org/doc/code.html中的说明设置GOPATH
,然后重新安装Go-SDL。例如:
# 从/usr/lib/go卸载Go-SDL
sudo go clean -i github.com/0xe2-0x9a-0x9b/Go-SDL/...
# 设置GOPATH
mkdir -p $HOME/go/src
export GOPATH=$HOME/go
# 将Go-SDL安装到$GOPATH
go get -v github.com/0xe2-0x9a-0x9b/Go-SDL/...
github.com/0xe2-0x9a-0x9b/Go-SDL
中的test
需要知道GOPATH
以查找一些资源文件(基于https://stackoverflow.com/questions/9443418/how-to-access-resource-files-after-the-go-tool-installed-the-executable)。
英文:
The go
command that you installed in /usr/lib/go/bin/
internally contains a default path that is used if the environment variable GOPATH
is missing. In case of the Ubuntu package this default path points to /usr/lib/go
. Thus the installation directory for Go-SDL is somewhere in /usr/lib/go/src
. Installing Go-SDL in this way requires root priviledges.
I recommend you setup GOPATH
as described in http://golang.org/doc/code.html and reinstall Go-SDL. For example:
# Uninstall Go-SDL from /usr/lib/go
sudo go clean -i github.com/0xe2-0x9a-0x9b/Go-SDL/...
# Setup GOPATH
mkdir -p $HOME/go/src
export GOPATH=$HOME/go
# Install Go-SDL into $GOPATH
go get -v github.com/0xe2-0x9a-0x9b/Go-SDL/...
The test
from github.com/0xe2-0x9a-0x9b/Go-SDL
needs to know GOPATH
to find some resource files (based on https://stackoverflow.com/questions/9443418/how-to-access-resource-files-after-the-go-tool-installed-the-executable).
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论