go - 错误响应 : [2] Build failed using GCP - Golang

标签 go google-cloud-platform

我正在尝试使用 Golang 将我的服务器部署到 Google Cloud Platform
我运行 gcloud app deploy cmd/web/app.yaml 并返回失败状态:未知:错误响应:[2]构建失败;查看构建日志以获取详细信息
在日志中打印了这个:

Starting Step #0
Step #0: Pulling image: gcr.io/gcp-runtimes/go1-builder@sha256:[...]
Step #0: sha256:[...]: Pulling from gcp-runtimes/go1-builder
Step #0: Digest: sha256:[...]
Step #0: Status: Downloaded newer image for gcr.io/gcp-runtimes/go1-builder@sha256:[...]
Step #0: main.go:8:2: cannot find package "github.com/GoogleCloudPlatform/cloudsql-proxy/proxy/dialers/mysql" in any of:
Step #0:    /usr/local/go/src/github.com/GoogleCloudPlatform/cloudsql-proxy/proxy/dialers/mysql (from $GOROOT)
Step #0:    /workspace/_gopath/src/github.com/GoogleCloudPlatform/cloudsql-proxy/proxy/dialers/mysql (from $GOPATH)
Step #0: routes.go:5:2: cannot find package "github.com/bmizerany/pat" in any of:
Step #0:    /usr/local/go/src/github.com/bmizerany/pat (from $GOROOT)
Step #0:    /workspace/_gopath/src/github.com/bmizerany/pat (from $GOPATH)
Step #0: main.go:7:2: cannot find package "github.com/go-sql-driver/mysql" in any of:
Step #0:    /usr/local/go/src/github.com/go-sql-driver/mysql (from $GOROOT)
Step #0:    /workspace/_gopath/src/github.com/go-sql-driver/mysql (from $GOPATH)
Step #0: middleware.go:6:2: cannot find package "github.com/justinas/nosurf" in any of:
Step #0:    /usr/local/go/src/github.com/justinas/nosurf (from $GOROOT)
Step #0:    /workspace/_gopath/src/github.com/justinas/nosurf (from $GOPATH)
Step #0: handlers.go:7:2: cannot find package "myProject/pkg/forms" in any of:
Step #0:    /usr/local/go/src/myProject/pkg/forms (from $GOROOT)
Step #0:    /workspace/_gopath/src/myProject/pkg/forms (from $GOPATH)
Step #0: app.go:4:2: cannot find package "myProject/pkg/models" in any of:
Step #0:    /usr/local/go/src/myProject/pkg/models (from $GOROOT)
Step #0:    /workspace/_gopath/src/myProject/pkg/models (from $GOPATH)
Finished Step #0
ERROR

我的 gcloud 配置是正确的,因为我连接到 Google SQL 并保存了数据。我在计算引擎中有代码,但我尝试在我的电脑上运行 gcloud app deploy cmd/web/app.yaml

最佳答案

外部包需要在本地才能进行构建。 Go 程序通常由来自许多不同来源的包组成。这些资源中的每一个都来自 GOPATH 或标准库。 ( Source of Explanation )

看看govendor . Govendor 将创建您的 vendor 文件夹并添加您的外部包。

// init govendor
govendor init

# Add existing GOPATH files to vendor.
govendor add +external

关于go - 错误响应 : [2] Build failed using GCP - Golang,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49659962/

相关文章:

nginx - 有关 Nginx 如何在 Google 计算引擎上使用 SSL 的详细信息

android-studio - Android Studio 3 - 如何添加云端点模块

logging - 根据字段查询 GCP 记录器以获取不同的日志

parsing - Golang 中的 RFC3339 时间解析

c - inb() 和 outb() Linux 系统调用的包装器

reference - 关于在 Go 上使用等号和 map 的说明

go - go 中的 Fcntl 不起作用

go - 如何检查 slice 界面元素是否具有相同的动态类型?

spring-boot - 上游连接错误或在 header 之前断开/重置。重置原因 : connection failure. Spring Boot 和 java 11

node.js - Google Cloud 作为 Node.js 的服务器