我有一个公共golang项目设置在
http://github.com/NeilGarb/budget,子包核心和api.我将项目保存在$GOPATH / src / github.com / NeilGarb / budget中.
我想使用Travis CI运行核心的银杏测试,但我在我的测试包中使用绝对导入,Travis抱怨它找不到所说的包.
例如,我的测试包括:
package user_test
import (
. "github.com/NeilGarb/budget/core"
)
运行ant在我的本地机器上工作正常,但是当travis尝试运行测试时,我得到:
core-test:
[exec] Failed to compile core:
[exec]
[exec] can't load package: package github.com/NeilGarb/budget/core: cannot find package "github.com/NeilGarb/budget/core" in any of:
[exec] /home/travis/.gvm/gos/go1.2/src/pkg/github.com/NeilGarb/budget/core (from $GOROOT)
[exec] /home/travis/.gvm/pkgsets/go1.2/global/src/github.com/NeilGarb/budget/core (from $GOPATH)
[exec]
[exec] Ginkgo ran in 714.967041ms
[exec] Test Suite Failed
我试图在我的测试中使用相对导入(即“../core”),这是有效的,但随后我的报道总是显示0%覆盖.
该怎么办? 🙁
最佳答案 我通过构建一个从$GOPATH / src / github.com / NeilGarb / budget到$TRAVIS_BUILD_DIR的符号链接解决了这个问题.