Go, Golang: 主程序的travis错误,go get -v

huangapple go评论83阅读模式
英文:

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 localgo 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

huangapple
  • 本文由 发表于 2014年7月28日 14:28:14
  • 转载请务必保留本文链接:https://go.coder-hub.com/24989531.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定