GO测试出现非常奇怪的错误-找不到包command-line-a/vendor。

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

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.

huangapple
  • 本文由 发表于 2016年4月5日 16:26:47
  • 转载请务必保留本文链接:https://go.coder-hub.com/36420953.html
匿名

发表评论

匿名网友

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

确定