Go应用程序的依赖关系不会通过Heroku上的godep安装 [英] Dependencies for Go app aren't installed through godep on Heroku

查看:119
本文介绍了Go应用程序的依赖关系不会通过Heroku上的godep安装的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I want to deploy Go application on Heroku, but I got an error like this:

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 / Godeps.json godeps save 命令。有什么问题?我注意到官方的启动回购有供应商

It works on my local environment and I added dependencies to Godeps/Godeps.json with godeps save command. What's the problem? I noticed official go-getting-started repo has vendor folder, so does it mean I have to have all dependencies into my repository?

这是我的 Godeps / Godeps.json

This is my 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"
        }
    ]
}


推荐答案

是的,您确实需要拥有所有的dep进入你的仓库。

Yes, You do need to have all dependencies into your repository.

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

In fact when you run godep save ./... and you are using go 1.5 or greater, Godep will automatically put dependencies in a directory named vendor (inside root directory of your repo). You need to commit both Godep and vendor directory to your repository.

在添加供应商目录时,请注意使用-f标志来添加其中的所有文件。这是需要的,因为某些文件/目录可能不会提交,具体取决于您的gitignore文件,这会导致heroku中的构建失败。作为一种标准的做法,你可以在使用godep添加依赖项后执行以下命令。
$ b

On side note while adding vendor directory use -f flag to add all files in it. It is needed as some files/directory might not be committed depending on your gitignore file and that will cause build failure in heroku. As a standard practice you can exeute following command to after adding dependencies using godep.


git add -f vendor / Godep /

git add -f vendor/ Godep/

git commit -a -m供应商依赖关系

git commit -a -m "Vendorizing dependencies"

这篇关于Go应用程序的依赖关系不会通过Heroku上的godep安装的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆