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 如何在node.js中或者java中给wav格式的音频编码成sil格式呢
  • ¥15 不小心不正规的开发公司导致不给我们y码,
  • ¥15 我的代码无法在vc++中运行呀,错误很多
  • ¥50 求一个win系统下运行的可自动抓取arm64架构deb安装包和其依赖包的软件。
  • ¥60 fail to initialize keyboard hotkeys through kernel.0000000000
  • ¥30 ppOCRLabel导出识别结果失败
  • ¥15 Centos7 / PETGEM
  • ¥15 csmar数据进行spss描述性统计分析
  • ¥15 各位请问平行检验趋势图这样要怎么调整?说标准差差异太大了
  • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题