Go: “all.bash”编译测试失败,显示”权限被拒绝”。

huangapple go评论77阅读模式
英文:

Go: "all.bash" compilation testing fails with "permission denied"

问题

我正在尝试在Bluehost共享服务器上安装Golang。

到目前为止,我在服务器上执行了以下操作:

cd ~
wget https://storage.googleapis.com/golang/go1.3.1.linux-amd64.tar.gz
tar -xvf go1.3.1.linux-amd64.tar.gz
rm go1.3.1.linux-amd64.tar.gz
vi .bashrc

我使用本地值设置了.bashrc文件,以便让Go正常工作。

# Go的配置
export GOPATH=$HOME/go
export PATH=$PATH:$GOPATH/bin

然后我运行了:

source ~/.bashrc
cd ~/go/src
./all.bash

一切都进行得很顺利,直到测试阶段:

警告:设置为GOROOT的GOPATH(/home1/username/go)无效
...
fork/exec /tmp/go-build667300507/cmd/addr2line/_test/addr2line.test: permission denied
FAIL	cmd/addr2line	0.053s
?   	cmd/cgo	[no test files]
...

之后每个测试都失败了,因为我无法访问/tmp目录。我在想也许有一个变量可以设置测试的位置,我可以访问到,但我还没有找到。

关于GOPATH set to GOROOT (/home1/username/go) has no effect。我运行了:

echo $GOROOT

但它没有被设置。那么出了什么问题呢?

英文:

I'm trying to install Golang in a Bluehost shared server.

I've done the following on the server so far:

cd ~
wget https://storage.googleapis.com/golang/go1.3.1.linux-amd64.tar.gz
tar -xvf go1.3.1.linux-amd64.tar.gz
rm go1.3.1.linux-amd64.tar.gz
vi .bashrc

I set the <code>.bashrc</code> file with the local values I want Go to work with.

# Configuration for Go
export GOPATH=$HOME/go
export PATH=$PATH:$GOPATH/bin

Then I run:

source ~/.bashrc
cd ~/go/src
./all.bash

And all goes well until the testing:

warning: GOPATH set to GOROOT (/home1/username/go) has no effect
...
fork/exec /tmp/go-build667300507/cmd/addr2line/_test/addr2line.test: permission denied
FAIL	cmd/addr2line	0.053s
?   	cmd/cgo	[no test files]
...

After that every single test fails, because I don't have access to /tmp. I was thinking maybe there is a variable to set the tests some place I do have access to, but I haven't found it.

About <code>GOPATH set to GOROOT (/home1/username/go) has no effect</code>. I've ran:

echo $GOROOT

And it is not set. So whats going on?

答案1

得分: 2

你应该将GOROOT添加到你的.bashrc文件中:

export GOROOT=$HOME/go1.3.1.linux-amd64/go
# 或者,根据解压缩的存档方式:
export GOROOT=$HOME/go
export PATH=$PATH:$GOROOT/bin

GOPATH应该设置为一个**工作区**,即你的项目所在的文件夹

export GOPATH=$HOME/goprojects
export PATH=$PATH:$GOPATH/bin

GOPATH中,你将会有srcbinpkg文件夹。


请记住,go1.3.1.linux-amd64.tar.gz存档文件是用于直接使用Go(它包含预编译的二进制文件)。

只有在你从源代码构建Go时,执行all.bash才有意义,但在这种情况下,你只需要源代码(go1.3.1.src.tar.gz)。

英文:

You should add GOROOT to your .bashrc:

export GOROOT=$HOME/go1.3.1.linux-amd64/go
# or, depending how the archive was un-tar&#39;d:
export GOROOT=$HOME/go
export PATH=$PATH:$GOROOT/bin

GOPATH should be set to a workspace, a folder where your projects will reside

export GOPATH=$HOME/goprojects
export PATH=$PATH:$GOPATH/bin

You will have src, bin and pkg in GOPATH.


Remember, the go1.3.1.linux-amd64.tar.gz archive is for using go directly (it has binaries pre-compiled).

Doing a all.bash makes sense only if you build go from sources, but in that case, you would need only the sources (go1.3.1.src.tar.gz).

huangapple
  • 本文由 发表于 2014年8月22日 02:29:33
  • 转载请务必保留本文链接:https://go.coder-hub.com/25433505.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定