gvm setting GOPATH in ubuntu 14.04

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

gvm setting GOPATH in ubuntu 14.04

问题

我安装了gvmgo1.3,接下来该怎么做?我正在尝试构建Revel,但是出现了以下错误:

无法加载包:在以下任何位置都找不到包“github.com/robfig/revel/cmd”:
	/home/cnaize/.gvm/gos/go1.3/src/pkg/github.com/robfig/revel/cmd(来自$GOROOT)
	($GOPATH未设置)

如何解决这个问题?

英文:

I installed gvm with go1.3, what next? I'm trying to build Revel, but I have the error:

can't load package: package github.com/robfig/revel/cmd: cannot find package "github.com/robfig/revel/cmd" in any of:
	/home/cnaize/.gvm/gos/go1.3/src/pkg/github.com/robfig/revel/cmd (from $GOROOT)
	($GOPATH not set)

How to fix this?

答案1

得分: 3

你需要使用gvm包和pkgset来启用它。

  gvm install go1.2.2
  gvm use go1.2.2
  gvm pkgset create revel-test
  gvm pkgset use revel-test
  go get github.com/reve/revel/cmd/revel
英文:

You need to enable the gvm package with pkgset

  gvm install go1.2.2
  gvm use go1.2.2
  gvm pkgset create revel-test
  gvm pkgset use revel-test
  go get github.com/reve/revel/cmd/revel

答案2

得分: 0

在安装了 GVM 后,可以使用以下命令来切换版本:

gvm use #version

请将 #version 替换为你想要使用的具体版本号。

英文:

after gvm install #version run:

 gvm use #version

答案3

得分: -1

你需要通过运行以下命令来设置你的GOPATH环境变量:

export GOPATH=/path/to/your/go/workspace

然后,使用以下命令获取包:

go get github.com/robfig/revel/cmd

注意,如果你在.bashrc中设置了GOPATH,你需要执行source ~/.bashrc命令使其生效(或重新打开终端)。

我建议你在每次进行操作时,不仅仅是提问,还应该阅读一些关于Go的文档或教程。你可以在go标签描述中找到一些资源。

英文:

You have to set your GOPATH environment variable by running a command like this

export GOPATH=/path/to/your/go/workspace

then get the package, by using the command

go get github.com/robfig/revel/cmd

Note if you set your GOPATH in .bashrc, you have to source ~/.bashrc to make it effective the first time (or re-open your terminal).

I suggest you also read some documentation or tutorial about go instead of just creating a new question each time you do something. A list of resources is available on the go tag description.

huangapple
  • 本文由 发表于 2014年6月19日 18:47:28
  • 转载请务必保留本文链接:https://go.coder-hub.com/24304746.html
匿名

发表评论

匿名网友

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

确定