错误响应:[2]使用GCP构建失败 - Golang

时间:2018-04-04 20:34:56

标签: go google-cloud-platform

我正在尝试使用Golang将我的服务器部署到Google Cloud Platform中 我跑gcloud app deploy cmd/web/app.yaml 并且返回Failure status: UNKNOWN: Error Response: [2] Build failed; check build logs for details
进入原木打印出这个:

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

2 个答案:

答案 0 :(得分:0)

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

看看govendor。 Govendor将创建您的供应商文件夹并添加您的外部包。

// init govendor
govendor init

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

答案 1 :(得分:0)

错误发生在app.yaml我不知道为什么,但我只是删除app.yamlapi_version: go1