在CentOS 5.x上安装Go

我想在CentOS 5.x上安装Go,但在此处转到Go网站 http://golang.org/doc/install 提到它不受支持。 </ p>

由于CentOS只是Linux的另一种形式,还有其他方法可以在CentOS上安装Go语言吗?</ p>

当我安装相同的语言并运行 在上述网站上提到的示例程序hello.go
我收到错误
hello.go:3:8:导入“ fmt”:找不到软件包
软件包运行时:导入“运行时”:找不到软件包</ p>
</ DIV>

展开原文

原文

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

dounang1974
dounang1974 您在编辑后的问题中提到的错误实际上看起来不像我在答案中讨论的问题。请仔细检查$goenv的输出是否合理。
7 年多之前 回复

5个回答



至少对于某些程序而言,它可以正常工作。 我有一个可以在RHEL 6.x上编译并在5.x和6.x上部署的生产程序,并且可以正常运行。</ p>

编辑:我以前在 1.0.3,但是几个月前我升级到了“ tip go”(即将成为1.1版本)。 在1.x以下,当接受TCP连接时,它会在5.9上崩溃,但是在我在邮件列表中报告它后几天,它已修复。</ p>
</ div>

展开原文

原文

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.



http://dave.cheney.net/2013/06/18/how-to-install-go-1-1-on-centos-5 </ p>

此页面很好地解释了CentOS-5内核缺少哪些内核原语,它们的影响以及可能的修复。</ p>
</ div>

展开原文

原文

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.



 %export GOROOT =〜/ 
%去运行test.go
test.go:3:8:import“ fmt“:找不到包
包运行时:导入” runtime“:找不到包
</ code> </ pre>

找不到“ runtime”包会告诉您 $ 未将GOROOT </ code>环境变量设置为golang根目录。
您需要设置 $ GOROOT </ code>。 另外,如果您使用外部软件包,请设置 $ GOPATH </ code>变量(有关更多信息,请参见 go help gopath </ code>)。</ p>

典型设置 (不特定于CentOS)将是:</ p>

  export GOROOT =“ / usr / local / go” 
export PATH =“ $ GOROOT / bin:$ PATH”
export GOPATH = /用户/ rodowi / gocode
</ code> </ pre>
</ div>

展开原文

原文

% 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



我很遗憾,由于CentOS 5.x的内核版本太老了,您不走运。 如果go运行时使用的功能只是该内核中不存在的功能,那么我看不到它如何工作的简单方法。</ p>
</ div>

展开原文

原文

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.



您可以下载rpm软件包并开始本地安装,请在下面进行检查并根据您的操作系统进行下载:</ p>

http://pkgs.org/download/golang </ p>

< p>,或者您也可以从源代码进行编译和构建:</ p>

http://dave.cheney.net/2013/06/18/how-to-install-go-1-1-on-centos- 5 </ p>
</ div>

展开原文

原文

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

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐