douchang8758 2017-03-24 09:59
浏览 65
已采纳

Golang Cloud SDK-gcloud应用部署无法找到导入包

according to the official documentation for Google App Engine Standard environment (Go API) the "preferred tooling to deploy a project" is now the Cloud SDK and so we moved to gcloud from goapp.

We are unable to deploy Go projects to GAE because all the sub-packages of every given project can't be found at "deploy time". The typical folder structure that we have been using for every GAE project was as follows:

-project-name
--app.yaml
--main.go
--assets
---package1
---package2

When global libraries were put in the system GOPATH everything worked smoothly.

Running gcloud app deploy we now get this:

You are about to deploy the following services:
 - yourproject/default/123456789 (from [/Path/to/app.yaml])
     Deploying to URL: [https://yourproject.appspot.com]

Do you want to continue (Y/n)?  Y

Beginning deployment of service [default]...
ERROR: (gcloud.app.deploy) Staging command [/path/to/yourproject/app.yaml /var/folders/b6/5ydn0wdn64jd32sxzzz48b7c0000gn/T/tmpbd4oiG] failed with return code [1].

------------------------------------ STDOUT ------------------------------------
------------------------------------ STDERR ------------------------------------
2017/03/24 10:25:58 failed analyzing /path/to/yourproject: cannot find package "yourpackage" in any of:
        ($GOROOT not set)
        /path/to/gopath/src/yourpackage (from $GOPATH)
GOPATH: /path/to/gopath
--------------------------------------------------------------------------------

while dev_appserver.py works perfectly keeping the same folder structure.

Did we miss something? How can we deploy to Google App Engine Standard environment using gcloud?

If the project structure needs to be changed: how? Is there official documentation about it?

Thanks in advance,

Edit -- Further infos:

Luigi-Mac-Pro:path/to/yourproject distudio$ gcloud version
Google Cloud SDK 148.0.0
app-engine-go 
app-engine-go-darwin-x86_64 1.9.50
app-engine-python 1.9.50
bq 2.0.24
bq-nix 2.0.24
core 2017.03.17
core-nix 2016.11.07
gcloud 
gcloud-deps 2017.03.17
gcloud-deps-darwin-x86_64 2017.02.21
gsutil 4.23
gsutil-nix 4.22
  • 写回答

1条回答 默认 最新

  • dstt1818 2017-03-24 14:27
    关注

    Google recommends keeping your dependencies outside of the app directory, and using GOPATH to refer them. In your case, that would mean doing the following:

    -project-name
    --app.yaml
    --main.go
    

    where main.go contains

    import (
        "package1"
        "package2"
    )
    

    And somewhere else:

    -my_packages
    --src
    ---package1
    ---package2
    

    And then set GOPATH environment variable to path/to/my_packages prior to running dev_appserver and gcloud app deploy.

    For the future

    We are working out the long term solution for properly vendoring packages inside your app directory – likely using Go's future native package manager. I'm sorry to say that we don't have a good way of supporting sub-packages for gcloud app deploy. This was an unfortunate side effect of compatibility with the App Engine Flexible environment.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器