Unit testing 执行Go测试时使用下划线(389;)代替正确的路径

Unit testing 执行Go测试时使用下划线(389;)代替正确的路径,unit-testing,testing,go,Unit Testing,Testing,Go,提前谢谢你的帮助 在我的Mac电脑上,当我执行go test./…时,正确的“路径”将在输出中输出: ok github.com/cnuss/server 0.008s ok github.com/cnuss/server/database 0.008s ? github.com/cnuss/server/handlers [no test files] ok github.com/cnuss/server/stats

提前谢谢你的帮助

在我的Mac电脑上,当我执行
go test./…
时,正确的“路径”将在输出中输出:

ok      github.com/cnuss/server             0.008s
ok      github.com/cnuss/server/database    0.008s
?       github.com/cnuss/server/handlers    [no test files]
ok      github.com/cnuss/server/stats       0.014s
但是,当我在Ubuntu 14.04 Trusty容器中构建时,路径已被替换为“u”(下划线):

路径的变化也反映在
-coverprofile
输出文件中,这反过来会影响我正在使用的一些覆盖工具


所以问题是,什么会影响执行
go test
时解析的路径?我的Mac Book上的行为是正确的。

您的Linux环境中可能没有设置
GOPATH

如果我在当前目录中创建一个文件
src/foo/foo.go
,内容为
package foo
,我可以看到区别:

$ unset GOPATH
$ go test ./src/foo
?       _/home/james/.../src/foo    [no test files]
$ export GOPATH=`pwd`
$ go test ./src/foo
?       foo [no test files]

如果没有设置
GOPATH
(或者在
GOPATH
之外有一个包),它的作用就好像这是一个相对导入一样。

go on each的版本是什么?就是这样,谢谢!在Linux环境中,GOPATH设置不正确。
$ unset GOPATH
$ go test ./src/foo
?       _/home/james/.../src/foo    [no test files]
$ export GOPATH=`pwd`
$ go test ./src/foo
?       foo [no test files]