英文:
cannot find package on travis-ci -golang
问题
我正在尝试在构建过程中运行一个Go脚本。该脚本导入了一个名为'custom'的包,但是我遇到了导入错误。
仓库名称是bis
。我运行的脚本是configbis.go
。导入configbis.go
的包是mymodule
。
项目结构如下:
bisrepo -------
| |
mymodule configbis.go
运行命令go run configbis.go
时,出现以下错误:
configbis.go:16:2: 找不到包"bisrepo/mymodule",可能的位置有:
/home/travis/.gvm/gos/go1.1.2/src/pkg/bisrepo/mymodule(来自$GOROOT)
/home/travis/.gvm/pkgsets/go1.1.2/global/src/bisrepo/mymodule(来自$GOPATH)
我尝试在configbis.go中导入mymodule,尝试了以下几种方式:
import "mymodule"
import "bisrepo/mymodule"
import "github.com/user/bisrepo/mymodule"
但是都没有成功。我已经没有更多的想法/选项了...
我阅读了travis-ci的文档,但发现它没有用。
英文:
I'm trying to run a go script as part of the build process. The script imports a 'custom' package. However I get this import error.
The repository name is bis
. The script which I run is configbis.go
. The package imported configbis.go
is mymodule
The project structure is as following:
bisrepo -------
| |
mymodule configbis.go
go run configbis.go
configbis.go:16:2: cannot find package "bisrepo/mymodule" in any of:
/home/travis/.gvm/gos/go1.1.2/src/pkg/bisrepo/mymodule (from $GOROOT)
/home/travis/.gvm/pkgsets/go1.1.2/global/src/bisrepo/mymodule (from $GOPATH)
I've tried to import mymodule in configbis.go as following:
import "mymodule"
import "bisrepo/mymodule"
import "github.com/user/bisrepo/mymodule"
None of them works. I run out of ideas/options ...
I read the the travis-ci documentation and I found it useless.
答案1
得分: 2
你可以尝试在你的.travis.yml
文件中添加以下内容:
install:
- go get github.com/user/bisrepo/mymodule
英文:
You could try to add something like that in your .travis.yml
:
install:
- go get github.com/user/bisrepo/mymodule
答案2
得分: 0
为了使用私有仓库,您必须提供一个 GitHub API 授权令牌(类似于在 Heroku 上部署引用私有仓库的 Go 项目时所需的操作)。您可以尝试在您的 .travis.yml
文件中添加以下内容:
before_install:
- echo "machine github.com login $GITHUB_AUTH_TOKEN" > ~/.netrc
这样做可以将您的 GitHub 授权令牌添加到 Travis CI 的配置中。
英文:
in order to use private repos you must provide a github api auth token (similarly so when deploying go projects which reference private repos on Heroku). You can try adding something like this in your .travis.yml
before_install:
- echo "machine github.com login $GITHUB_AUTH_TOKEN" > ~/.netrc
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论