du5910 2018-06-30 12:12
浏览 65
已采纳

使用go和dep的Heroku:“推送被拒绝:无法编译Go应用”

I am trying to deploy my Go Heroku app that uses dep to manage dependencies. However, when I attempt to push it, the logs say this.

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: 

It nags and complains about a GOPATH that is already correct on my system. I wonder why this is happening? My dep configuration file looks like this.

# 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"

What is wrong, and how can I fix it?

  • 写回答

2条回答 默认 最新

  • dongli7236 2018-07-01 20:13
    关注

    It looks like your import paths in

    main.go:7:2: ==> "backend/database"

    and

    main.go:6:2: ==> "backend/user"

    are not set correctly. Are you able to run your app locally? Are those two imports your own, user-defined packages? If so, please provide a schematic of your project directory structure. I am pretty sure fixing the import paths will fix the problem.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog