英文:
GO test gives very strange error - cannot find package command-line-a/vendor
问题
我已经升级到GO 1.6,现在在运行go test
时遇到了非常奇怪的错误。
pawel@pawel:~/work/src/...../web/workers$ go test email_test.go
# command-line-arguments
email_test.go:16:2: 找不到包"command-line-a/vendor/github.com/jpoehls/gophermail",在以下任何位置都找不到:
/usr/local/go/src/command-line-a/vendor/github.com/jpoehls/gophermail (来自$GOROOT)
/home/pawel/work/src/command-line-a/vendor/github.com/jpoehls/gophermail (来自$GOPATH)
/home/pawel/work/src/...../web/_vendor/src/command-line-a/vendor/github.com/jpoehls/gophermail
FAIL command-line-arguments [设置失败]
我还尝试使用go test email_test.go email.go
运行它,但结果是一样的。我在整个项目和vendor中使用grep搜索了"command-line",但没有找到它。
运行go run email.go
可以正常工作。我的项目依赖项在目录vendor
中(它在更高的一级),其中包含github.com/jpoehls/gophermail
。
英文:
I've update to GO 1.6 and now I get very strange error when running go test
pawel@pawel:~/work/src/...../web/workers$ go test email_test.go
# command-line-arguments
email_test.go:16:2: cannot find package "command-line-a/vendor/github.com/jpoehls/gophermail" in any of:
/usr/local/go/src/command-line-a/vendor/github.com/jpoehls/gophermail (from $GOROOT)
/home/pawel/work/src/command-line-a/vendor/github.com/jpoehls/gophermail (from $GOPATH)
/home/pawel/work/src/...../web/_vendor/src/command-line-a/vendor/github.com/jpoehls/gophermail
FAIL command-line-arguments [setup failed]
I've also tried to run it with go test email_test.go email.go
but result is the same. I grep for "command-line" in my whole project and vendor and haven't find it.
Running go run email.go
works correctly. My project dependencies are in directory vendor
(which is one level higher), it contains github.com/jpoehls/gophermail
答案1
得分: 3
如@volker在评论中解释的那样,我的问题是我想测试文件而不是包。当我重新组织我的项目并简单地通过go test
进行测试时,它可以正常工作。
然而,这并不能解释为什么我会得到如此奇怪的错误。
英文:
As @volker explained in a comment, my problem was that I wanted to test files instead of packages.
When I reorganize my project and test simply by go test
it works fine.
Nevertheless it doesn't explain why I get such a strange error.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论