how to use remote packages on travis-ci | GO

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

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.

huangapple
  • 本文由 发表于 2014年3月27日 08:19:52
  • 转载请务必保留本文链接:https://go.coder-hub.com/22675821.html
匿名

发表评论

匿名网友

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

确定