goconvey 请在你的 $GOPATH 中运行 goconvey,无法导入绝对路径。

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

goconvey Please run goconvey from within your $GOPATH cannot import absolute path

问题

我正在设置Go,并尝试使用http://goconvey.co/使一个简单的项目工作。

我将$GOPATH设置为/Users/joe/Desktop/playground/go,并且当我运行

$ go get github.com/smartystreets/goconvey

它会将所有内容下载到我的GOPATH中。

所以当我在这里创建一个项目
/Users/joe/Desktop/playground/go/some-project

并运行goconvey时,我得到以下错误信息:

2015/02/04 14:41:05 shell.go:93: 请在$GOPATH内运行goconvey

我的测试代码是:

package main

import (
	. "github.com/smartystreets/goconvey/convey"
	"testing"
)

func TestStuff(t *testing.T) {
	Convey("Truth", t, func() {
		Convey("is falsey", func() {
			So(false, ShouldBeFalse)
		})
	})

}

我不知道为什么它找不到文件。
当我运行go test时,它完美地工作。
请帮忙解决一下?

英文:

I'm setting up go and trying to get a simple project working with http://goconvey.co/

I have my $GOPATH set to /Users/joe/Desktop/playground/go

and when I run

> $ go get github.com/smartystreets/goconvey

it downloads all good to my GOPATH

so when I create a project here
/Users/joe/Desktop/playground/go/some-project

and run goconvey I get

2015/02/04 14:41:05 shell.go:93: Please run goconvey from within your $GOPATH

My testing code is

package main

import (
	. "github.com/smartystreets/goconvey/convey"
	"testing"
)

func TestStuff(t *testing.T) {
	Convey("Truth", t, func() {
		Convey("is falsey", func() {
			So(false, ShouldBeFalse)
		})
	})

}

I don't know why it connot find the files.
When I run go test it works perfectly.
Help?

答案1

得分: 3

所有的Go代码都需要放在$GOPATH/src/目录下,以便GoConvey UI正常工作。

所以,如果你的$GOPATH设置为:

/Users/joe/Desktop/playground/go

那么你需要将你的项目放在:

/Users/joe/Desktop/playground/go/src/some-project

你的代码目前在:

/Users/joe/Desktop/playground/go/some-project

话虽如此,错误信息可能应该修改为类似以下内容:

> 请在$GOPATH/src目录下运行goconvey(另外,符号链接可能会有问题)。

在这种情况下,@VonC所提到的变量名称可能有点不准确。

英文:

All go code needs to be within $GOPATH/src/ for the GoConvey UI to work.

So, if your $GOPATH is set to

/Users/joe/Desktop/playground/go

then you will need to put your project at

/Users/joe/Desktop/playground/go/src/some-project

Your code is currently at

/Users/joe/Desktop/playground/go/some-project

Having said all that, the error message should probably be modified to read something like this:

> Please run goconvey from within $GOPATH/src (also, symlinks might be problematic).

The name of the variable referenced by @VonC is probably a slight misnomer in this case.

huangapple
  • 本文由 发表于 2015年2月4日 11:50:43
  • 转载请务必保留本文链接:https://go.coder-hub.com/28313189.html
匿名

发表评论

匿名网友

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

确定