在我的repo的子目录中,我有一些package main
的脚本来显示我的包的一些示例用法。但是在Travis上进行测试时,这会给我带来以下错误。
repo
example-dir
sub-dir
main.go // this gives me error like the following
github.com/~/directory-for-main-program
The command "go get -v ./..." failed. Retrying, 2 of 3.
我只在Travis中看到此错误,而不是在go test
的本地计算机中。
是否有分离主程序并且仍能通过Travis测试?
答案 0 :(得分:1)
使用main.go
中的正确路径,这是正确的方法,或使用build constraints来禁用该文件:
// +build local
package main
//other code
然后使用go build -tags local
或go run -tags local