【问题标题】:Go project with third party packages on Heroku在 Heroku 上使用第三方包进行项目
【发布时间】:2014-06-24 08:08:51
【问题描述】:

将 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 getgo install 按预期在本地运行。该项目是在本地构建和运行的。我相信我的包结构是正确的,GOPATHGOROOT 是正确的。我正在使用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"
        }
    ]
}

我错过了什么吗?还有什么我应该检查的吗?谢谢!

【问题讨论】:

  • buildpack 支持 godep,查看文档github.com/tools/godep
  • 谢谢。我已经在使用godep了。我又通读了几次自述文件,尝试重置我的 godep 依赖项,尝试了一个不必要的 .godir 文件,以及其他一些事情,但仍然出现 Heroku 部署错误。我在项目中尝试了 gopack 作为 godep 的解决方法/替代方案,我能够提供依赖项并成功部署到 Heroku。

标签: heroku deployment go


【解决方案1】:

您是否在开发中运行godep save

来自 Godep 自述文件:

$ 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.

--- 更新 ---

我看到了你的 repo,在 heroku http://warm-depths-3154.herokuapp.com/ 上,按照步骤操作

rm -Rf  gopack.config .godir .gopack
godep save
git add --all . // please commit the Godep folder
git commit -m 'using godep, removed gopack' 

(提交https://github.com/dukex/gournay/commit/0de2390835357879a34ea452a56eeeb6391e5ba8

【讨论】:

  • 是的。运行godep save 后,我运行cat Godeps/Godeps.json 并粘贴上面的输出。如果你想用 godep 试试,我把gournay project放在github上。
猜你喜欢
  • 2016-11-25
  • 2019-08-16
  • 1970-01-01
  • 2016-02-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-08-28
  • 2020-02-08
相关资源
最近更新 更多