【问题标题】:Dependencies for Go app aren't installed through godep on HerokuGo 应用程序的依赖项不是通过 Heroku 上的 godep 安装的
【发布时间】:2016-08-13 14:57:18
【问题描述】:

我想在 Heroku 上部署 Go 应用程序,但出现如下错误:

remote: -----> Go app detected
remote: -----> Checking Godeps/Godeps.json file.
remote: -----> Using go1.6.3
remote:  !!    Installing package '.' (default)
remote:  !!    
remote:  !!    
remote: -----> Running: go install -v -tags heroku . 
remote: main.go:9:2: cannot find package "github.com/go-martini/martini" in any of:
remote:     /app/tmp/cache/go1.6.3/go/src/github.com/go-martini/martini (from $GOROOT)
remote:     /tmp/build_3c0222e075a91a3363e590a0169d6fb6/.heroku/go/src/github.com/go-martini/martini (from $GOPATH)

它适用于我的本地环境,我使用godeps save 命令将依赖项添加到Godeps/Godeps.json。有什么问题?我注意到官方go-getting-started repo 有vendor 文件夹,这是否意味着我必须将所有依赖项都放入我的存储库中?

这是我的Godeps/Godeps.json:

{
    "ImportPath": "github.com/mikamikuh/oauth2-server-tester",
    "GoVersion": "go1.6",
    "GodepVersion": "v74",
    "Deps": [
        {
            "ImportPath": "github.com/codegangsta/inject",
            "Comment": "v1.0-rc1-10-g33e0aa1",
            "Rev": "33e0aa1cb7c019ccc3fbe049a8262a6403d30504"
        },
        {
            "ImportPath": "github.com/go-martini/martini",
            "Comment": "v1.0-185-gc257c41",
            "Rev": "c257c412d547ac70fcaf5596c1a50a7cb832c1fc"
        }
    ]
}

【问题讨论】:

    标签: heroku go godeps


    【解决方案1】:

    是的,您确实需要将所有依赖项都放入您的存储库中。

    事实上,当你运行 godep save ./... 并且使用 go 1.5 或更高版本时,Godep 会自动将依赖项放在名为 vendor 的目录中(在你的 repo 的根目录中)。您需要将 Godep 和供应商目录都提交到您的存储库。

    在添加供应商目录时使用 -f 标志添加其中的所有文件。它是必需的,因为根据您的 gitignore 文件可能不会提交某些文件/目录,这将导致 heroku 中的构建失败。作为标准做法,您可以在使用 godep 添加依赖项后执行以下命令。

    git add -f vendor/ Godep/

    git commit -a -m "供应依赖"

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-10-16
      • 2020-03-01
      • 1970-01-01
      • 1970-01-01
      • 2016-07-16
      • 2012-10-04
      • 2015-02-26
      相关资源
      最近更新 更多