普通网友 2016-08-13 14:57
浏览 35
已采纳

在Heroku上未通过Godep安装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)

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?

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"
        }
    ]
}
  • 写回答

1条回答 默认 最新

  • douyan2470 2016-08-14 08:30
    关注

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

    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.

    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 commit -a -m "Vendorizing dependencies"

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 求帮我调试一下freefem代码
  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图