how to use remote packages on travis-ci | GO

≯℡__Kan透↙ 提交于 2019-12-13 04:41:34

问题


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:


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.



来源:https://stackoverflow.com/questions/22675821/how-to-use-remote-packages-on-travis-ci-go

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!