douli4337 2015-11-29 01:26
浏览 39
已采纳

在已部署的Appengine应用中,用户ID可以超过64位吗?

I am working on an appengine app in Go and when I tried to get an appengine User's ID and convert it to a 64-bit int with this code:

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

I got this error:

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

Does this error occur on appengine IDs in deployed code as well?

  • 写回答

2条回答 默认 最新

  • dtrz17917 2015-11-29 03:20
    关注

    The ID field of the User type is defined with type string. Just because it contains digits, there is no guarantee that it fits into an int64.

    The Go AppengineSDK uses values that fit into int64, but this is not true in production environment. They are usually longer than the max value of int64. They are handed to you as strings, so treat them like that: strings. Nothing forces you to convert them to a number. I don't know where you got the idea to convert them to numbers, but don't do that. They are strings.

    Note: User.ID is not to be mistaken with Key.IntID() which is defined to be of type int64.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度