1 回答
TA贡献1811条经验 获得超5个赞
只需用*InsertOp值替换*GetOp值,然后读取它们的Value字段:
package main
import "fmt"
import "gopkg.in/couchbaselabs/gocb.v1"
func main() {
getKeys()
}
func getKeys() {
myCluster, err := gocb.Connect("couchbase://<couchbase-address>")
if err != nil {
fmt.Println("cluster error:", err)
}
myBucket, err := myCluster.OpenBucket("Test", "") //case sensitive!
if err != nil {
fmt.Println("bucket error:", err)
}
var items []gocb.BulkOp
items = append(items, &gocb.GetOp{Key: "document_name_1"})
items = append(items, &gocb.GetOp{Key: "document_name_2"})
err = myBucket.Do(items)
if err != nil {
fmt.Println("Do error:", err)
panic(err)
}
for _, g := range items {
//"downcast" the instance back to its concrete type - GetOp
t := g.(*gocb.GetOp)
fmt.Println(t)
}
}
- 1 回答
- 0 关注
- 211 浏览
添加回答
举报