我最近开始在 App Engine 上使用 golang 探索 Google Identity Kit。我正在使用googlesamples/identity-toolkit-go中的示例。在查看代码时,我发现了以下一些 appengine 包:
"google.golang.org/appengine"
"google.golang.org/appengine/datastore"
对于我正在开发的 GAE Golang 应用程序,我使用 GAE SDK 来运行使用goapp run
. 但是,在我的代码中,我只引用
"appengine"
"appengine/datastore"
因为这指向位于提取的 go appengine sdk 中的 golang src。
我是否需要改用google.golang.org
appengine 包?
在意识到身份工具包方法所期望的 appengine.Context 与我使用的不匹配后,我才发现这一点。我收到了这个错误
`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)`
尽管我使用appengine.NewContext(r)
示例解释。