heroku - 在 Heroku 上使用第三方包进行 Go 项目

标签 heroku deployment go

将 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"
        }
    ]
}

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

最佳答案

你在开发中运行 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.

---更新---

我在 heroku 上看到了你的 repo 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 )

关于heroku - 在 Heroku 上使用第三方包进行 Go 项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23745092/

相关文章:

戈朗 : Preferred way to tag a struct with aribtrary data

ruby-on-rails - 为 Heroku 上的用户提供 Rails 3 自定义域

ruby-on-rails - 从另一个本地分支推送到 heroku

heroku - 是否可以将 golang db.Query() 输出转储到字符串?

asp.net - 在没有代码隐藏文件的情况下部署 ASP.NET 应用程序时如何工作?

go - 编码无法从 Go 访问的 C 对象

ruby-on-rails - Postgres + Heroku SSL SYSCALL 错误

javascript - tomcat无法访问javascript文件夹

.net - 如何与 .NET 3.5 SP1 Bootstrap 通信

mysql - 如何将值从 MySQL 传递到模板