我爱占星网 我爱占星网
首页
编程
java
php
前端
首页 编程 java php 前端

使用Golang从Google的数据存储区获取ID

I have a Go struct:

type Foo struct{
  Name: string
  Age: int
}

I am able to save and retrieve Foos in datastore. So I may edit a Foo, I want to get the ID that datastore assigns a Foo, to use in an anchor. I verified that IDs are assigned using Google's datastore dashboard, but how do I get the ID off of a retrieved Foo?

GetAll returns the keys along with any error.

keys, err := q.GetAll(c, &foos)

keys is an array of datastore.Key

近期文章

  • 调用以指针作为接收者的指针的方法表达式
  • 使用Go语言发送带有以太网标头的原始数据包
  • Go 1.0.2如何使用zlib压缩时提高速度
  • 在CentOS 5.x上安装Go
  • 我无法在for循环中同时写入文件-Goroutine无法正常工作
  • 如何逐行读取文件并返回已读取多少字节?
  • Golang,如何分享价值-消息还是互斥体?
  • 打印字节时的不同行为
  • 动态HTML的GO模板
  • 从地图值附加切片不会影响地图
  • 如何在Go中将新字符分配给字符串?
  • 如何在Linux中编写文本模式gui? [关闭]
  • 函数返回变量的地址…最终是另一个变量吗?
  • 我可以破坏[] byte和字符串之间的数据转换吗?
  • 。(data_type)方法到底调用/做什么?
  • 含义:变量<-struct {} {}
  • go例行程序的奇怪行为
  • 简单并发队列
  • Go中的bytes.String()与bytes.Bytes()
  • 您能拥有一张没有价值的地图吗?

Copyright ©2022 我爱占星 All Rights Reserved.

浙ICP备2022030071号-1

部分图文来自网络,如有侵犯您的版权,请告诉我们删除

友情链接:代码精华