2

我正在设置 go 并尝试使用http://goconvey.co/进行一个简单的项目

我的 $GOPATH 设置为 /Users/joe/Desktop/playground/go

当我跑步时

$ 去获取 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 时,它运行良好。帮助?

4

1 回答 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 引用的变量的名称可能有点用词不当。

于 2015-02-04T19:40:57.930 回答