带有go和dep的Heroku:`push rejected:未能编译go应用程序`

带有go和dep的Heroku:`push rejected:未能编译go应用程序`,go,heroku,Go,Heroku,我正在尝试部署使用dep管理依赖关系的Go Heroku应用程序。但是,当我尝试推送它时,日志会这样说 Total 818 (delta 147), reused 0 (delta 0) remote: Compressing source files... done. remote: Building source: remote: remote: -----> Go app detected remote: -----> Fetching jq... done remote:

我正在尝试部署使用
dep
管理依赖关系的Go Heroku应用程序。但是,当我尝试推送它时,日志会这样说

Total 818 (delta 147), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote: 
remote: -----> Go app detected
remote: -----> Fetching jq... done
remote: -----> Fetching tq... done
remote:  !!    
remote:  !!    Deprecated or unsupported version of go (go1.10.1)
remote:  !!    See https://devcenter.heroku.com/articles/go-support#go-versions for supported version information.
remote:  !!    
remote: -----> Installing go1.10.1
remote: -----> Fetching go1.10.1.linux-amd64.tar.gz... done
remote:  !!    Installing package '.' (default)
remote:  !!    
remote:  !!    To install a different package spec set 'metadata.heroku.pkg-spec' in 'Gopkg.toml'
remote:  !!    
remote:  !!    For more details see: https://devcenter.heroku.com/articles/go-apps-with-dep#build-configuration
remote:  !!    
remote: -----> Fetching dep... done
remote: -----> Fetching any unsaved dependencies (dep ensure)
remote: -----> Running: go install -v -tags heroku . 
remote: main.go:7:2: cannot find package "backend/database" in any of:
remote:         /tmp/tmp.2P0hB8CCKz/.go/src/main/vendor/backend/database (vendor tree)
remote:         /app/tmp/cache/go1.10.1/go/src/backend/database (from $GOROOT)
remote:         /tmp/tmp.2P0hB8CCKz/.go/src/backend/database (from $GOPATH)
remote: main.go:6:2: cannot find package "backend/user" in any of:
remote:         /tmp/tmp.2P0hB8CCKz/.go/src/main/vendor/backend/user (vendor tree)
remote:         /app/tmp/cache/go1.10.1/go/src/backend/user (from $GOROOT)
remote:         /tmp/tmp.2P0hB8CCKz/.go/src/backend/user (from $GOPATH)
remote:  !     Push rejected, failed to compile Go app.
remote: 
remote:  !     Push failed
remote: Verifying deploy...
remote: 
remote: !       Push rejected to thindan.
remote: 
它唠叨并抱怨我的系统上已经正确的GOPATH。我想知道为什么会这样?我的dep配置文件如下所示

# Gopkg.toml example
#
# Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md
# for detailed Gopkg.toml documentation.
#
# required = ["github.com/user/thing/cmd/thing"]
# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"]
#
# [[constraint]]
#   name = "github.com/user/project"
#   version = "1.0.0"
#
# [[constraint]]
#   name = "github.com/user/project2"
#   branch = "dev"
#   source = "github.com/myfork/project2"
#
# [[override]]
#  name = "github.com/x/y"
#  version = "2.4.0"


[[constraint]]
  name = "github.com/boltdb/bolt"
  version = "1.3.1"

[[constraint]]
  branch = "master"
  name = "golang.org/x/crypto"

[metadata.heroku]
root-package = "backend"
go-version = "1.10.1"
build = ["."]
ensure = "false"

出了什么问题,我如何修复它?

它看起来像是您的导入路径

main.go:7:2:
==>
“后端/数据库”

main.go:6:2:
==>
“后端/用户”


设置不正确。你能在本地运行你的应用程序吗?这两个导入是您自己的、用户定义的包吗?如果是,请提供项目目录结构示意图。我非常确定修复导入路径将修复此问题。

为了防止有人仍然存在此问题,我通过指定以下Gopkg.toml来修复此问题:

[metadata.heroku]
  root-package = "the-name-of-my-proyect"
  install = ["./..."]

在我的例子中,我没有指定go版本,所以它采用默认版本。我还指定了install-[“/…”],因为我有一个monorepo,其中go代码位于子文件夹中

我修复了它!目录和目标名称错误。