gpt4 book ai didi

heroku - 无法在 Heroku 上部署具有 Godeps 依赖项的 go 应用程序

转载 作者:IT王子 更新时间:2023-10-29 01:41:53 26 4
gpt4 key购买 nike

当我试图在 heroku 上推送我的项目时出现以下错误

git push heroku master
Counting objects: 88, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (86/86), done.
Writing objects: 100% (88/88), 18.85 MiB | 686.00 KiB/s, done.
Total 88 (delta 13), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Go app detected
remote: -----> Checking Godeps/Godeps.json file.
remote: -----> Using go1.7.3
remote: -----> Running: go install -v -tags heroku ./...
remote: main.go:8:2: cannot find package "github.com/Sirupsen/logrus" in any of:
remote: /app/tmp/cache/go1.7.3/go/src/github.com/Sirupsen/logrus (from $GOROOT)
remote: /tmp/tmp.Ffkjp5c5US/.go/src/github.com/Sirupsen/logrus (from $GOPATH)
remote: main.go:6:2: cannot find package "github.com/gin-gonic/gin" in any of:
remote: /app/tmp/cache/go1.7.3/go/src/github.com/gin-gonic/gin (from $GOROOT)
remote: /tmp/tmp.Ffkjp5c5US/.go/src/github.com/gin-gonic/gin (from $GOPATH)
remote: ! Push rejected, failed to compile Go app.
remote:
remote: ! Push failed
remote: Verifying deploy...
remote:
remote: ! Push rejected to eerie-wizard-18479.
remote:
To https://git.heroku.com/eerie-wizard-18479.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/eerie-wizard-18479.git'

在提交和推送 heroku 之前,我小心地保存了一个 godep save ./...,这是我的 Godeps.json 文件:(此文件中存在 logrus 和 gin)

{
"ImportPath": "github.com/sbouaked/neo-fundations",
"GoVersion": "go1.7",
"GodepVersion": "v74",
"Packages": [
"./..."
],
"Deps": [
{
"ImportPath": "github.com/Sirupsen/logrus",
"Comment": "v0.10.0-38-g3ec0642",
"Rev": "3ec0642a7fb6488f65b06f9040adc67e3990296a"
},
{
"ImportPath": "github.com/gin-gonic/gin",
"Comment": "v1.0-2-g3900df0",
"Rev": "3900df04d2a88e22beaf6a2970c63648b9e1b0e1"
},
{
"ImportPath": "github.com/gin-gonic/gin/binding",
"Comment": "v1.0-2-g3900df0",
"Rev": "3900df04d2a88e22beaf6a2970c63648b9e1b0e1"
},
{
"ImportPath": "github.com/gin-gonic/gin/render",
"Comment": "v1.0-2-g3900df0",
"Rev": "3900df04d2a88e22beaf6a2970c63648b9e1b0e1"
},
{
"ImportPath": "github.com/golang/protobuf/proto",
"Rev": "98fa357170587e470c5f27d3c3ea0947b71eb455"
},
{
"ImportPath": "github.com/manucorporat/sse",
"Rev": "ee05b128a739a0fb76c7ebd3ae4810c1de808d6d"
},
{
"ImportPath": "golang.org/x/net/context",
"Rev": "4bb47a1098b37d69980d96237e2ae4ff56bb5a95"
},
{
"ImportPath": "golang.org/x/sys/unix",
"Rev": "c200b10b5d5e122be351b67af224adc6128af5bf"
},
{
"ImportPath": "gopkg.in/go-playground/validator.v8",
"Comment": "v8.18.1",
"Rev": "5f57d2222ad794d0dffb07e664ea05e2ee07d60c"
},
{
"ImportPath": "gopkg.in/yaml.v2",
"Rev": "a5b47d31c556af34a302ce5d659e6fea44d90de0"
}
]
}

我在 this post 上看到了我必须提交 vendor/,但我不想这样做。现在真的有解决办法吗?

最佳答案

如果您查看 Go 的 heroku buildpack ( https://github.com/heroku/heroku-buildpack-go/blob/master/bin/compile ),它目前不支持 GoDeps,因为传统的 GoDeps 样式依赖管理已在 Go v1.6 中被弃用。您可以将 GoDeps 依赖项转换为销售依赖项,这应该可以解决这个问题。

个人推荐使用glide:https://github.com/Masterminds/glide

但你也可以使用:

https://github.com/kardianos/govendor

https://github.com/constabulary/gb

因为构建包的编译脚本支持这些。

其中每一个都支持将 GoDeps 自动转换为其格式。

如果你有 ./vendor/vendor.json Heroku 将自动使用 govendor,除非你将 Heroku 配置为使用其他东西。

此页面也可能有帮助 https://elements.heroku.com/buildpacks/heroku/heroku-buildpack-go

从技术上讲,它确实支持 Godep,但似乎您必须使用旧版本的 Go 或将 GoDeps 移至 vendor。

关于heroku - 无法在 Heroku 上部署具有 Godeps 依赖项的 go 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40376830/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com