英文:
Go, Golang : travis error for main program, go get -v
问题
在我的存储库的子目录中,我有一些带有package main
的脚本,用于展示我的包的一些示例用法。但是当在Travis上进行测试时,会出现以下错误。
github.com/~/directory-for-main-program
The command "go get -v ./..." failed. Retrying, 2 of 3.
我只在Travis上看到这个错误,而在本地机器上使用go test
时没有看到。
有没有办法将主程序分离出来,同时仍然能够通过Travis的测试?
英文:
In my repo's subdirectory, I have some scripts with package main
to show some example usage fo my package. But this gives me the following errors when being tested on 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.
I see this error only in Travis , not in local machine with go test
.
Is there anyway to separate the main program and still able to pass the Travis testing?
答案1
得分: 1
要么在你的main.go
中使用正确的路径,这是正确的方式,要么使用构建约束来禁用那个文件:
// +build local
package main
//其他代码
然后使用go build -tags local
或go run -tags local
来进行本地构建。
英文:
Either use the correct path in your main.go
, which is the proper way or use build constraints to disable that file:
// +build local
package main
//other code
then to locally build it use go build -tags local
or go run -tags local
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论