dongpao1926 2013-04-19 11:28
浏览 11
已采纳

为什么我的存储实体使用默认值?

I am saying

data := Thing {
    date:     time.Now().UnixNano()   
    name:     "foo",
    value:    5,
}
_, err := datastore.Put(c, datastore.NewIncompleteKey(c, "stuff", nil), &data)
if err != nil {
    http.Error(w, err.Error(), http.StatusInternalServerError)
    return
}

What is getting stored is {0, "", 0}. I expect to see something like {1366370653722376000, "foo", 5}. What am I doing wrong?

Note: I am using the dev appserver.

  • 写回答

1条回答 默认 最新

  • dongtang7347 2013-04-19 11:32
    关注

    You must export the names you want to be visible outside your package. To achieve that you must use as its first letter any Unicode upper-case-class (which ASCII upper case letters are a subset), e.g. Date instead of date, Name instead of name, etc.

    Without that the datastore.Put cannot "see" (using reflection) the fields.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 交替优化波束形成和ris反射角使保密速率最大化
  • ¥15 树莓派与pix飞控通信
  • ¥15 自动转发微信群信息到另外一个微信群
  • ¥15 outlook无法配置成功
  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程