英文:
Installing Go on CentOS 5.x
问题
我想在CentOS 5.x上安装Go,但是Go的网站http://golang.org/doc/install提到它不支持该版本。
由于CentOS只是Linux的一个不同版本,是否仍然有办法在CentOS上安装Go语言?
当我安装相同的版本并运行上述网站中提到的示例程序hello.go时,我遇到了错误
hello.go:3:8: import "fmt": cannot find package
package runtime: import "runtime": cannot find package
英文:
I want to install Go on CentOS 5.x, but Go website here http://golang.org/doc/install mentions that it is not supported.
Is there still some way to install Go Language on CentOS since CentOS is just a different flavour of Linux?
When I installed the same and ran the sample program hello.go mentioned at above website
I got the error
hello.go:3:8: import "fmt": cannot find package
package runtime: import "runtime": cannot find package
答案1
得分: 5
找不到“runtime”包告诉您$GOROOT
环境变量未设置为golang根目录。您需要设置$GOROOT
。如果您使用外部包,还应该设置$GOPATH
变量(有关更多信息,请参见go help gopath
)。
一个典型的设置(不特定于CentOS)可能是:
export GOROOT="/usr/local/go"
export PATH="$GOROOT/bin:$PATH"
export GOPATH=/Users/rodowi/gocode
英文:
% export GOROOT=~/
% go run test.go
test.go:3:8: import "fmt": cannot find package
package runtime: import "runtime": cannot find package
Not finding the "runtime" package tells you that the $GOROOT
enviroment variable isn't set to golang root directory.
You need to set $GOROOT
. Also you should set the $GOPATH
variable if you use external packages (go help gopath
for more information).
A typical setup (not specific to CentOS) would be:
export GOROOT="/usr/local/go"
export PATH="$GOROOT/bin:$PATH"
export GOPATH=/Users/rodowi/gocode
答案2
得分: 3
至少对于一些程序来说,它运行得很好。我有一个在RHEL 6.x上编译并部署在5.x和6.x上的生产程序,它没有任何问题。
编辑:我过去使用的是1.0.3版本,但几个月前我升级到了“tip go”(即将发布的1.1版本)。在1.x版本下,当接受一个TCP连接时,它会在5.9上崩溃,但在我在邮件列表上报告后的几天内就修复了这个问题。
英文:
At least for some programs it works fine. I have a production program that I compile on RHEL 6.x and deploy on 5.x and 6.x and it is working without any problems.
Edit: I used to use it under 1.0.3, but a few months ago I upgraded to "tip go" (the soon to be 1.1 version). Under 1.x it'd crash on 5.9 when accepting a tcp connection but that was fixed a few days after I reported it on the mailing list.
答案3
得分: 2
这个页面很好地解释了CentOS-5内核缺少的内核原语,它们的影响以及可能的修复方法。
英文:
http://dave.cheney.net/2013/06/18/how-to-install-go-1-1-on-centos-5
This page explains rather well what kernel primitives are missing from the CentOS-5 kernel, their impact, and possible fixes.
答案4
得分: 0
我很抱歉,由于CentOS 5.x内核版本过旧,你可能运气不佳。如果Go运行时使用的功能在该内核中根本不存在,那么我看不到它能够正常工作的简单方法。
英文:
I'm affraid you're out of luck because of the bit too much aged kernel version of CentOS 5.x. If the go runtime uses features simply not present in that kernel, then I see no easy way how it could work.
答案5
得分: 0
你可以下载rpm包并在本地安装,根据你的操作系统选择以下链接进行下载:
http://pkgs.org/download/golang
或者你也可以选择从源代码编译和构建:
http://dave.cheney.net/2013/06/18/how-to-install-go-1-1-on-centos-5
英文:
you could download the rpm package and begin installing locally, check below and download according to your OS:
http://pkgs.org/download/golang
or you could alternatively compile and build from source:
http://dave.cheney.net/2013/06/18/how-to-install-go-1-1-on-centos-5
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论