安装gorilla后,对文件的访问权限被拒绝。

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

GO: Permission denied to file after installing gorilla

问题

我是你的中文翻译助手,以下是翻译好的内容:

我是SO的新手,对GO也是一个相对新手。在我的本地服务器上顺利构建和运行GO代码,直到我需要使用Gorilla工具包中的一些包。

我在命令行中运行的命令如下:

mkdir $HOME/mygo
export GOPATH=$HOME/mygo
cd mygo

go get github.com/gorilla/mux

我是根据这里的示例进行的操作:http://golang.org/doc/articles/go_command.html。在"Getting started with the Go Command"和这里http://www.gorillatoolkit.org/。

之后,我将我的main.go代码导入到mygo文件夹中。我的目录结构如下:

Workspace
    pkg
    src
    main.go

然而,当我运行go build main.go,并尝试运行./main时,我得到了以下错误信息:

-bash: ./main.go: Permission denied

发生了什么?请帮忙解决。谢谢!

英文:

I am new to SO and a relatively new beginner to GO. I was building and running GO code smoothly on my local server until I had to use some of the packages from Gorilla toolkit.

What I ran in the command line:

mkdir $HOME/mygo
export GOPATH=$HOME/mygo
cd mygo

go get github.com/gorilla/mux

I did this based on the example from here: http://golang.org/doc/articles/go_command.html. Under gettng started with the Go Command and here http://www.gorillatoolkit.org/.

After this, I imported my main.go code into the mygo folder. My directory folder looks like this:

Workspace
    pkg
    src
    main.go

However, when I ran go build main.go, and tried to run ./main, I got

-bash: ./main.go: Permission denied

What is happening?? Please help. Thanks!

答案1

得分: 3

首先,我强烈建议阅读http://linuxcommand.org/learning_the_shell.php,然后完成Go的教程(http://tour.golang.org/)。

其次,就像@JimB提到的,你不能直接执行main.go(你可以使用binfmt_misc,但我不会在这里解释)。

因此,运行可执行文件的步骤如下:

go build -o main
./main

或者直接运行:

go run main.go
英文:

First I highly recommend reading http://linuxcommand.org/learning_the_shell.php, then going through the Go tour.

Second, like @JimB mentioned, you can't execute main.go directly like that (you can use binfmt_misc but I'm not gonna explain that here).

So the steps to run your executable are:

go build -o main
./main

Or directly:

go run main.go

huangapple
  • 本文由 发表于 2014年8月7日 23:21:38
  • 转载请务必保留本文链接:https://go.coder-hub.com/25186284.html
匿名

发表评论

匿名网友

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

确定