google-app-engine - 在已部署的应用引擎应用程序中,用户 ID 是否可以超过 64 位?

标签 google-app-engine go

我正在使用 Go 开发 Appengine 应用程序,当我尝试获取 Appengine User 的 ID 并使用以下代码将其转换为 64 位 int 时:

id, err := strconv.ParseInt(user.ID, 10, 64)

我遇到了这个错误:

ERROR: error executing inner: strconv.ParseInt: parsing "185804764220139124118": value out of range

此错误是否也发生在已部署代码中的应用引擎 ID 上?

最佳答案

UserID 字段类型定义为 string 类型。仅仅因为它包含数字,不能保证它适合 int64

Go AppengineSDK 使用适合 int64 的值,但在生产环境中并非如此。它们通常比 int64 的最大值长。它们以 string 的形式传递给您,因此请像这样对待它们:string。没有什么会强制您将它们转换为数字。我不知道你从哪里得到将它们转换为数字的想法,但不要那样做。它们是字符串

注意:User.ID 不能与 Key.IntID() 混淆它被定义为 int64 类型。

关于google-app-engine - 在已部署的应用引擎应用程序中,用户 ID 是否可以超过 64 位?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33978419/

相关文章:

python - 使用 Flask-appengine-template 时出现奇怪的 KeyProperty 失败

go - 如何从 golang 中的 math floor 函数中获取整数结果?

go - 主机参数在mux.Vars()中不可用

google-app-engine - 为什么我在 setUp() 中创建的实体无法通过 nosetests 访问?

java - GAE 消息服务

list - Golang 中 LinkedList<T> 的等价物是什么

go - 解析片段并找到所有顶级定义

parallel-processing - 数据通道关闭时 Goroutines 不退出

google-app-engine - 无法使用 Web API 在 Google App Engine 中创建应用程序。错误 : 409 - This application already exists and cannot be re-created

python - 为什么我的 webapp2 import/Google App Engine "Hello, World"不工作?