我正在设置 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: Please run goconvey from within your $GOPATH
我的测试代码是
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 时,它工作得很好。 帮忙?
最佳答案
所有 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
话虽如此,错误消息可能应该修改为如下内容:
Please run goconvey from within $GOPATH/src (also, symlinks might be problematic).
在这种情况下,@VonC 引用的变量名称可能有点用词不当。
关于goconvey 请从 $GOPATH 中运行 goconvey 无法导入绝对路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28313189/