为什么这个 Go 构建在 Heroku 上失败了?它在本地构建没有问题
Why is this Go build failing on Heroku? It builds locally with no issue
有谁能告诉我为什么这个构建在 heroku 上失败了?
我试过寻找替代包并整理 mod 文件,甚至删除它并重做。
这是我的构建日志
Overview Resources Deploy Metrics Activity Access Settings
Activity Feed Build LogID f8e9d5ce-0d8f-4e8e-8b2a-661c4d1f68f7
-----> Building on the Heroku-20 stack
-----> Go app detected
-----> Fetching stdlib.sh.v8... done
----->
Detected go modules via go.mod
----->
Detected Module Name: github.com/xxxxxx/xxxxxx-xxxxxx
----->
!! The go.mod file for this project does not specify a Go version
!!
!! Defaulting to go1.12.17
!!
!! For more details see: https://devcenter.heroku.com/articles/go-apps-with-modules#build-configuration
!!
-----> Using go1.12.17
-----> Determining packages to install
Detected the following main packages to install:
github.com/xxxxxx/xxxxxx-xxxxxx
-----> Running: go install -v -tags heroku github.com/xxxxxx/xxxxxx-companion
github.com/vektah/gqlparser/v2/ast
github.com/agnivade/levenshtein
github.com/mitchellh/mapstructure
github.com/vektah/gqlparser/v2/gqlerror
github.com/99designs/gqlgen/graphql
# github.com/99designs/gqlgen/graphql
../codon/tmp/cache/go-path/pkg/mod/github.com/99designs/gqlgen@v0.13.0/graphql/error.go:21:5: undefined: errors.As
github.com/99designs/gqlgen/graphql/errcode
github.com/vektah/gqlparser/v2/lexer
github.com/hashicorp/golang-lru/simplelru
github.com/vektah/gqlparser/v2/parser
github.com/hashicorp/golang-lru
github.com/gorilla/websocket
github.com/vektah/gqlparser/v2/validator
github.com/99designs/gqlgen/graphql/playground
github.com/xxxxxx/xxxxxx-xxxxxx/graph/model
github.com/xxxxxx/xxxxxx-xxxxxx/database
github.com/99designs/gqlgen/graphql/introspection
github.com/vektah/gqlparser/v2/validator/rules
github.com/go-sql-driver/mysql
github.com/vektah/gqlparser/v2
! Push rejected, failed to compile Go app.
! Push failed
这是我的 go.mod 文件:
module github.com/xxxxxx/xxxxxx-xxxxxx
go 1.15
require (
github.com/99designs/gqlgen v0.13.0
github.com/go-sql-driver/mysql v1.5.0
github.com/hashicorp/golang-lru v0.5.1 // indirect
github.com/mitchellh/mapstructure v0.0.0-20180220230111-00c29f56e238 // indirect
github.com/stretchr/testify v1.5.1 // indirect
github.com/vektah/gqlparser/v2 v2.1.0
gopkg.in/yaml.v2 v2.2.8 // indirect
)
我完全不知所措,我怀疑它与不正确的版本有关,但构建日志并没有给我太多继续下去的信息。我以后如何诊断此类问题?
谢谢。
回来标记这个完成,我发现通过在 go mod 文件中指定
// +heroku goVersion go1.15
Go buildback 支持在构建之前指定版本控制的任意注释。
https://github.com/heroku/heroku-buildpack-go#go-module-specifics
也感谢用户@JimB 为我指明了正确的方向。
您可以在 go.mod
文件中添加指令 // +heroku goVersion go1.15
。
module somemodule
// +heroku goVersion go1.15
go 1.15
require (
// ...
)
那么它应该是这样的。
remote: Detected go modules via go.mod
remote: ----->
remote: Detected Module Name: somemodule
remote: ----->
remote: -----> New Go Version, clearing old cache
remote: -----> Installing go1.15
文档:https://github.com/heroku/heroku-buildpack-go#go-module-specifics
Go Module Specifics
You can specify specific package spec(s) via the go.mod
file's // +heroku install
directive (see below).
// +heroku goVersion <version>
: the major version of go you would
like Heroku to use when compiling your code. If not specified this
defaults to the buildpack's [DefaultVersion].
有谁能告诉我为什么这个构建在 heroku 上失败了?
我试过寻找替代包并整理 mod 文件,甚至删除它并重做。
这是我的构建日志
Overview Resources Deploy Metrics Activity Access Settings
Activity Feed Build LogID f8e9d5ce-0d8f-4e8e-8b2a-661c4d1f68f7
-----> Building on the Heroku-20 stack
-----> Go app detected
-----> Fetching stdlib.sh.v8... done
----->
Detected go modules via go.mod
----->
Detected Module Name: github.com/xxxxxx/xxxxxx-xxxxxx
----->
!! The go.mod file for this project does not specify a Go version
!!
!! Defaulting to go1.12.17
!!
!! For more details see: https://devcenter.heroku.com/articles/go-apps-with-modules#build-configuration
!!
-----> Using go1.12.17
-----> Determining packages to install
Detected the following main packages to install:
github.com/xxxxxx/xxxxxx-xxxxxx
-----> Running: go install -v -tags heroku github.com/xxxxxx/xxxxxx-companion
github.com/vektah/gqlparser/v2/ast
github.com/agnivade/levenshtein
github.com/mitchellh/mapstructure
github.com/vektah/gqlparser/v2/gqlerror
github.com/99designs/gqlgen/graphql
# github.com/99designs/gqlgen/graphql
../codon/tmp/cache/go-path/pkg/mod/github.com/99designs/gqlgen@v0.13.0/graphql/error.go:21:5: undefined: errors.As
github.com/99designs/gqlgen/graphql/errcode
github.com/vektah/gqlparser/v2/lexer
github.com/hashicorp/golang-lru/simplelru
github.com/vektah/gqlparser/v2/parser
github.com/hashicorp/golang-lru
github.com/gorilla/websocket
github.com/vektah/gqlparser/v2/validator
github.com/99designs/gqlgen/graphql/playground
github.com/xxxxxx/xxxxxx-xxxxxx/graph/model
github.com/xxxxxx/xxxxxx-xxxxxx/database
github.com/99designs/gqlgen/graphql/introspection
github.com/vektah/gqlparser/v2/validator/rules
github.com/go-sql-driver/mysql
github.com/vektah/gqlparser/v2
! Push rejected, failed to compile Go app.
! Push failed
这是我的 go.mod 文件:
module github.com/xxxxxx/xxxxxx-xxxxxx
go 1.15
require (
github.com/99designs/gqlgen v0.13.0
github.com/go-sql-driver/mysql v1.5.0
github.com/hashicorp/golang-lru v0.5.1 // indirect
github.com/mitchellh/mapstructure v0.0.0-20180220230111-00c29f56e238 // indirect
github.com/stretchr/testify v1.5.1 // indirect
github.com/vektah/gqlparser/v2 v2.1.0
gopkg.in/yaml.v2 v2.2.8 // indirect
)
我完全不知所措,我怀疑它与不正确的版本有关,但构建日志并没有给我太多继续下去的信息。我以后如何诊断此类问题?
谢谢。
回来标记这个完成,我发现通过在 go mod 文件中指定
// +heroku goVersion go1.15
Go buildback 支持在构建之前指定版本控制的任意注释。
https://github.com/heroku/heroku-buildpack-go#go-module-specifics
也感谢用户@JimB 为我指明了正确的方向。
您可以在 go.mod
文件中添加指令 // +heroku goVersion go1.15
。
module somemodule
// +heroku goVersion go1.15
go 1.15
require (
// ...
)
那么它应该是这样的。
remote: Detected go modules via go.mod
remote: ----->
remote: Detected Module Name: somemodule
remote: ----->
remote: -----> New Go Version, clearing old cache
remote: -----> Installing go1.15
文档:https://github.com/heroku/heroku-buildpack-go#go-module-specifics
Go Module Specifics
You can specify specific package spec(s) via the
go.mod
file's// +heroku install
directive (see below).
// +heroku goVersion <version>
: the major version of go you would like Heroku to use when compiling your code. If not specified this defaults to the buildpack's [DefaultVersion].