去绝对进口和Travis CI

标签 go travis-ci

我在 http://github.com/NeilGarb/budget 设置了一个公共(public) golang 项目,带有子包 core 和 api。我将项目保存在 $GOPATH/src/github.com/NeilGarb/budget 中。

我想使用 Travis CI 运行 core 的 ginkgo 测试,但我在我的测试包中使用了绝对导入,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 的符号链接(symbolic link)解决了这个问题。

关于去绝对进口和Travis CI,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22560778/

相关文章:

postgresql - Golang增量数

google-app-engine - 为什么 "go test -v"没有看到 GOPATH 或 GOPATH 但 "go env"有?

github - 首次添加存储库时构建 Travis CI

go - 如何在 Travis-CI 上将 Go 项目从 Linux 交叉编译到 Windows

r - Travis-CI:在 loadVignetteBuilder 中未找到 Knit

regex - 如何匹配所有重叠模式

go - 如何解决 "too many arguments to return"问题

dictionary - 戈朗 : Using a defined interface in a Map Value

rust - 在 Travis CI 上交叉编译简单 crate 时找不到链接器 cc

python - 如何让 Python 看到通过 apt 安装的模块?