【问题标题】:Google App Engine import issue (golang) in "App Engine flexible environment" (formerly known as "Managed VMs")“App Engine 柔性环境”(以前称为“托管 VM”)中的 Google App Engine 导入问题 (golang)
【发布时间】:2016-10-05 12:39:36
【问题描述】:

我正在“App Engine 柔性环境”(以前称为“托管虚拟机”)上直接使用 golang 开发 API。

到目前为止,我一直在我的 .go 文件中使用这种导入:

import ( 
        "appengine"
        "appengine/datastore"
        ...)

最近我决定使用 Google Cloud Storage 来存储图像。它需要导入“cloud.google.com/go/storage”。我的问题是我无法使用此导入(未找到)或我用于 appengine 导入的任何其他短版本(“go/storage”)部署应用程序。

经过大量研究,我发现了这个:https://github.com/golang/appengine#user-content-3-update-code-using-deprecated-removed-or-modified-apis

它指定如何将使用短导入(已弃用,如我的)的应用程序迁移到完整导入(使用明确的存储库,如“google.golang.org/appengine”)

我按照程序并使用他们提供的脚本来更新我的代码 (aefix)。他们还说要将此行添加到我的 app.yaml 文件中:

vm : true

如果我这样做了,我会在运行“gcloud app deploy”时收到此错误消息:

ERROR: (gcloud.app.deploy) Your application does not satisfy all of the requirements for a runtime of type [go].  Please correct the errors and try again.

如果我不这样做,我的导入都不起作用,我收到以下错误:

can't find import: "google.golang.org/appengine/datastore"

这是我的 app.yaml 文件:

runtime: go
api_version: go2
#vm : true

handlers:
   - url: /.*
   script: _go_app

当然,所有的导入都在 $GOPATH/src/ 下的服务器上,所以它们并没有真正丢失,我猜是更糟糕的引用。

我被这个问题困扰了好几天了,任何形式的帮助都将不胜感激!

谢谢

【问题讨论】:

    标签: google-app-engine go google-cloud-storage


    【解决方案1】:

    很抱歉 - 我们有一些文档要更新。您不能将 golang/appengine 包与 App Engine 柔性环境一起使用。 aefix 工具在这里也不起作用。您想在此处使用 Go 客户端库,而不是 App Engine Go SDK:

    https://github.com/GoogleCloudPlatform/google-cloud-go

    如果您之前使用的是 vm:true,则需要升级到 env:flex - 说明(以及有关 go 应用引擎库的注释)在这里:

    https://cloud.google.com/appengine/docs/flexible/go/upgrading

    如果您有任何问题,请告诉我!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-21
      • 2016-10-07
      • 1970-01-01
      • 2019-04-24
      • 2018-12-31
      • 2018-03-29
      • 2018-11-28
      • 2017-09-30
      相关资源
      最近更新 更多