dr5648
2018-04-04 20:34
浏览 49
已采纳

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

I'm trying deploy my server using Golang into Google Cloud Platform
I run gcloud app deploy cmd/web/app.yaml And was return Failure status: UNKNOWN: Error Response: [2] Build failed; check build logs for details
Into the logs was print this:

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

My gcloud configuration is correct because I have a connection to Google SQL and I save the data. I have the code in a Compute Engine, but I try to run gcloud app deploy cmd / web / app.yaml on my pc

图片转代码服务由CSDN问答提供 功能建议

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

 开始步骤#0 
步骤#0:提取图片:gcr  .io / gcp-runtimes / go1-builder @ sha256:[...] 
步骤#0:sha256:[...]:从gcp-runtimes / go1-builder 
中提取步骤#0:摘要:sha256:[  ...] 
步骤#0:状态:已下载gcr.io/gcp-runtimes/go1-builder@sha256的较新映像:[...] 
步骤#0:main.go:8:2:找不到包 
步骤#0:/usr/local/go/src/github.com/GoogleCloudPlatform/cloudsql-proxy/proxy/dialers/mysql中的任何一个,都为“ github.com/GoogleCloudPlatform/cloudsql-proxy/proxy/dialers/mysql”  (来自$ GOROOT)
步骤#0:/workspace/_gopath/src/github.com/GoogleCloudPlatform/cloudsql-proxy/proxy/dialers/mysql(来自$ GOPATH)
步骤#0:routes.go:5:2: 在以下任何位置都找不到软件包“ github.com/bmizerany/pat”:
步骤#0:/usr/local/go/src/github.com/bmizerany/pat(来自$ GOROOT)
步骤#0:/ workspace /  _gopath / src / github.com / bmizerany / pat(来自$ GOPATH)
步骤#0:main.go:7:2:找不到软件包“ github.com/g  o-sql-driver / mysql”中的任何一个:
步骤#0:/usr/local/go/src/github.com/go-sql-driver/mysql(来自$ GOROOT)
步骤#0:/ workspace /  _gopath / src / github.com / go-sql-driver / mysql(来自$ GOPATH)
步骤#0:middleware.go:6:2:在以下任意位置都找不到软件包“ github.com/justinas/nosurf”:\  nStep#0:/usr/local/go/src/github.com/justinas/nosurf(来自$ GOROOT)
Step#0:/workspace/_gopath/src/github.com/justinas/nosurf(来自$ GOPATH)\  nStep#0:handlers.go:7:2:在以下任何位置都找不到软件包“ myProject / pkg / forms”:
Step#0:/ usr / local / go / src / myProject / pkg / forms(来自$ GOROOT)  
步骤#0:/ workspace / _gopath / src / myProject / pkg / forms(来自$ GOPATH)
步骤#0:app.go:4:2:在以下任意位置都找不到软件包“ myProject / pkg / models”:\  n步骤#0:/ usr / local / go / src / myProject / pkg / models(来自$ GOROOT)
步骤#0:/ workspace / _gopath / src / myProject / pkg / models(来自$ GOPATH)
完成的步骤#0  
ERROR 
   
 
 

我的gcloud配置正确,因为我已经连接到Google SQL,并且保存了 数据。 我在Compute Engine中有代码,但是我尝试在PC上运行 gcloud app deploy cmd / web / app.yaml

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • dongqian2021 2018-04-09 09:13
    已采纳

    The error was in app.yaml i don't have much idea why but i just delete into app.yaml the line api_version: go1

    点赞 评论
  • duanhuai7532 2018-04-05 02:19

    External packages need to be local for the build to take place. Go programs are often comprised of packages from many different sources. Each one of these sources are pulled in from the GOPATH or from the standard library. (Source of Explanation)

    Take a look at govendor. Govendor will create your vendor folder and add your external packages.

    // init govendor
    govendor init
    
    # Add existing GOPATH files to vendor.
    govendor add +external
    
    点赞 评论

相关推荐 更多相似问题