英文:
Go project with third party packages on Heroku
问题
在将Go项目部署到Heroku时,安装pq包失败。我也在heroku buildpack github issues上发布了这个问题。
部署时的错误信息如下:
-----> Running: godep go install -tags heroku ./...
gournay.go:10:3: cannot find package "github.com/lib/pq" in any of:
/app/tmp/cache/go1.2.1/go/src/pkg/github.com/lib/pq (from $GOROOT)
/tmp/build_ce268203-801e-4dfc-a56c-d70698d6c5bf/.heroku/g/src/github.com/andyatkinson/gournay/Godeps/_workspace/src/github.com/lib/pq (from $GOPATH)
/tmp/build_ce268203-801e-4dfc-a56c-d70698d6c5bf/.heroku/g/src/github.com/lib/pq
godep: go exit status 1
在本地运行go get
和go install
时一切正常。项目在本地构建和运行。我相信我的包结构是正确的,并且GOPATH
和GOROOT
也是正确的。我正在使用godep
,它创建了下面的依赖文件。pq包的源代码似乎已经复制到了项目中,所以看起来应该可以从该源代码编译。
~/go/src/github.com/andyatkinson/gournay (master) $ cat Godeps/Godeps.json
{
"ImportPath": "github.com/andyatkinson/gournay",
"GoVersion": "go1.2.1",
"Deps": [
{
"ImportPath": "github.com/lib/pq",
"Rev": "c808a1bb644594ca717ac61f71e6b0e454b835e2"
}
]
}
我是否漏掉了什么?还有其他需要检查的地方吗?谢谢!
英文:
When deploying a Go project to Heroku, installation of the pq package fails. I've posted this in heroku buildpack github issues as well.
Error at deploy time:
-----> Running: godep go install -tags heroku ./...
gournay.go:10:3: cannot find package "github.com/lib/pq" in any of:
/app/tmp/cache/go1.2.1/go/src/pkg/github.com/lib/pq (from $GOROOT)
/tmp/build_ce268203-801e-4dfc-a56c-d70698d6c5bf/.heroku/g/src/github.com/andyatkinson/gournay/Godeps/_workspace/src/github.com/lib/pq (from $GOPATH)
/tmp/build_ce268203-801e-4dfc-a56c-d70698d6c5bf/.heroku/g/src/github.com/lib/pq
godep: go exit status 1
go get
and go install
run locally as expected. The project is built and running locally. I believe my package structure is correct, and GOPATH
and GOROOT
are correct. I am using godep
which creates the dependencies file below. The source for the pq package appears to be copied into the project, so it seems like it would compile from that source.
~/go/src/github.com/andyatkinson/gournay (master) $ cat Godeps/Godeps.json
{
"ImportPath": "github.com/andyatkinson/gournay",
"GoVersion": "go1.2.1",
"Deps": [
{
"ImportPath": "github.com/lib/pq",
"Rev": "c808a1bb644594ca717ac61f71e6b0e454b835e2"
}
]
}
Am I missing something? Anything else I should check? Thanks!
答案1
得分: 1
你在开发过程中是否运行了godep save
命令?
根据godep的README文件:
$ godep save
这将把依赖项列表保存到文件Godeps/Godeps.json中,并将它们的源代码复制到Godeps/_workspace目录中。请仔细阅读其内容,确保它看起来合理。然后将该文件提交到版本控制。
--- 更新 ---
我看到了你的存储库,并在Heroku上查看了http://warm-depths-3154.herokuapp.com/,请按照以下步骤操作:
rm -Rf gopack.config .godir .gopack
godep save
git add --all . // 请提交Godep文件夹
git commit -m 'using godep, removed gopack'
(提交记录https://github.com/dukex/gournay/commit/0de2390835357879a34ea452a56eeeb6391e5ba8)
英文:
Do you run godep save
on development?
from godep README:
$ godep save
This will save a list of dependencies to the file Godeps/Godeps.json,
and copy their source code into Godeps/_workspace. Read over its
contents and make sure it looks reasonable.
Then commit the file to version control.
--- UPDATE ---
I see your repo, and up on heroku http://warm-depths-3154.herokuapp.com/, follow the steps
rm -Rf gopack.config .godir .gopack
godep save
git add --all . // please commit the Godep folder
git commit -m 'using godep, removed gopack'
(the commit https://github.com/dukex/gournay/commit/0de2390835357879a34ea452a56eeeb6391e5ba8)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论