“App Engine灵活环境”中的Google App Engine导入问题(golang) (以前称为“管理的VM”) [英] Google App Engine import issue (golang) in "App Engine flexible environment" (formerly known as "Managed VMs")

查看:432
本文介绍了“App Engine灵活环境”中的Google App Engine导入问题(golang) (以前称为“管理的VM”)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我直接在App Engine灵活环境(以前称为托管虚拟机)中开发API中的API。



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

  import(
appengine
appengine / datastore
...)

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



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



它指定如何将使用短进口的应用程序(不赞成像我的一样)迁移到完全导入(存储库显式为google.golang.org/appengine)。
$ b

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

  vm:true 

如果我这样做了,我得到了运行'gcloud app deploy'的错误消息:

 错误:(gcloud.app.deploy)您的应用程序不满足[go]类型运行时的所有要求。请更正错误并重试。 

如果我不这样做,我的导入都不起作用,并且出现以下错误:

 找不到导入:google.golang.org/appengine/datastore



这是我的app.yaml文件:

 运行时:go 
api_version:go2
#vm:true

处理程序:
- url:/.*
脚本:_go_app

当然,所有的导入都在$ GOPATH / src /下的服务器上,所以它们并不是真的丢失,更糟糕



我在这个问题上坚持了几天,任何形式的帮助都不胜感激!



感谢

解决方案

非常抱歉 - 我们有一些文档需要更新。您不能在App Engine灵活环境中使用golang / appengine包。 aefix工具也不会在这里工作。



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



如果您以前使用过 vm:true ,您需要升级到 env:flex - 说明引擎库)在这里:



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



让我知道您是否有任何问题!

I am developing an API in golang directly on the "App Engine flexible environment" (formerly known as "Managed VMs").

So far, i have been using this kind of import in my .go files :

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

Recently I decided to use Google Cloud Storage to store images. It requires the import of "cloud.google.com/go/storage". My problem is that i'm unable to deploy the app with this import (not found), or any other short version ("go/storage") like I use for the appengine import.

After much research, I found this : https://github.com/golang/appengine#user-content-3-update-code-using-deprecated-removed-or-modified-apis

It specifies how to migrate an application using short imports (deprecated, like mine) to full imports (with repository explicit like "google.golang.org/appengine")

I followed the procedure and used the script they provide to update my code (aefix). They also say to add this line to my app.yaml file :

vm : true

If I do, I got this error message running '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.

If I don't, none of my imports are working and I get the following error :

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

Here is my app.yaml file :

runtime: go
api_version: go2
#vm : true

handlers:
   - url: /.*
   script: _go_app

Of course, all the imports are on the server under $GOPATH/src/ so they're not really missing, more badly referenced I guess.

I'm stuck on this problem since several days, any help of any kind would be appreciated !

Thanks

解决方案

So sorry - we have some docs to go update. You cannot use the golang/appengine package with the App Engine flexible environment. The aefix tool won't work here either. Instead of the App Engine Go SDK, you want to use the Go client library here:

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

If you were previously using vm:true, you will need to upgrade to env:flex - the instructions (and the note on the go app engine library) are here:

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

Let me know if you have any questions!

这篇关于“App Engine灵活环境”中的Google App Engine导入问题(golang) (以前称为“管理的VM”)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆