英文:
how to use remote packages on travis-ci | GO
问题
当我运行一个Go脚本(go run example.go)时,我得到了这个错误:
/home/travis/.gvm/gos/go1.1.2/src/pkg/github.com/user/examplepackage(来自$GOROOT)
/home/travis/.gvm/pkgsets/go1.1.2/global/src/github.com/user/examplepackage(来自$GOPATH)
example.go使用以下方式导入了一个包:
import "github.com/user/examplepackage"
travis.yml
文件如下:
install:
- go get ...
before_script:
- go run example.go
travis-ci团队不知道如何安装和配置GOPATH和GOROOT吗?
英文:
when I run a go script ( go run example.go ) I get this error
/home/travis/.gvm/gos/go1.1.2/src/pkg/github.com/user/examplepackage (from $GOROOT)
/home/travis/.gvm/pkgsets/go1.1.2/global/src/github.com/user/examplepackage (from $GOPATH)
example.go imports a package using
import "github.com/user/examplepackage"
The travis.yml
file looks like :
install:
- go get ...
before_script:
- go run example.go
travis-ci team doesn't know to install and configure GOPATH and GOROOT ?
答案1
得分: 1
你应该在你的.travis.yml文件中添加language: go
,这样Travis CI就知道这个项目是一个Go项目,并正确设置GOPATH和GOROOT。默认情况下,Travis CI在install
步骤中运行go get -d -v ./... && go build -v ./...
,所以我认为你可以将你的.travis.yml更改为以下内容:
language: go
before_script:
- go run example.go
如果go run example.go
是你的测试脚本,你应该将它更改为以下内容:
language: go
script:
- go run example.go
这里有更多关于Travis CI的Go文档链接。
英文:
You should add language: go
to your .travis.yml file, that way Travis CI knows that the project is a Go project and sets up the GOPATH and GOROOT correctly. By default, Travis CI runs go get -d -v ./... && go build -v ./...
in the install
step, so I think you may be able to change your .travis.yml to this:
language: go
before_script:
- go run example.go
If the go run example.go
is your test script, you should change it to this:
language: go
script:
- go run example.go
There's more Go docs for Travis CI here.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论