dongshi7433 2015-11-30 15:01
浏览 76

哪些Golang软件包可用于Google App Engine

I recently started to explore the Google Identity Kit using golang on the App Engine. I was going off of the samples in the googlesamples/identity-toolkit-go. In looking at the code, I found some appengine packages for the following:

"google.golang.org/appengine"
"google.golang.org/appengine/datastore"

For the GAE Golang application that I am working on, I use the GAE SDK to run the application using goapp run. However, in my code, I only reference

"appengine"
"appengine/datastore"

because this points to the golang src located in the extracted go appengine sdk.

Do I need to be using the google.golang.org appengine packages instead?

I only found this out after realizing that the appengine.Context that is expected by the identity kit methods did not match what I was using. I received this error

`cannot use c (type "appengine".Context) as type "golang.org/x/net/context".Context in argument to client.ValidateToken. "appengine".Context does not implement "golang.org/x/net/context".Context (missing Deadline method)`

despite me using appengine.NewContext(r) as the example explained.

  • 写回答

1条回答 默认 最新

  • dpj96988 2015-12-17 02:47
    关注

    I recommend using the google.golang.org/appengine packages if you can. They play nicer with the language, primarily because of the reason you mention (context is a net/context), and also because the libraries are newer and often have more features. In particular if you plan to use other Google services (like Google Cloud Storage) you'll have a much easier time using the newer libraries.

    But they're also better because - since they're just regular, importable packages - they play nicer with the standard set of go tools: goimports for auto-formatting, gocode for autocomplete, etc..

    However they are not entirely complete. There are some features missing or deprecated. In my experience it used to be that the major missing feature was the aetest package, which has since been ported, so there's now very few reasons not to switch.

    评论

报告相同问题?

悬赏问题

  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大