1 回答

TA貢獻(xiàn)1735條經(jīng)驗(yàn) 獲得超5個(gè)贊
doc.DataTo(&b)該程序僅在返回錯(cuò)誤時(shí)將博客附加到結(jié)果中。
編寫如下代碼:
var bs models.Blogs
iter := client.Collection("blogs").Documents(ctx)
defer iter.Stop() // add this line to ensure resources cleaned up
for {
doc, err := iter.Next()
if err == iterator.Done {
break
}
if err != nil {
// Handle error, possibly by returning the error
// to the caller. Break the loop or return.
... add code here
}
var b models.Blog
if err := doc.DataTo(&b); err != nil {
// Handle error, possibly by returning the error
// to the caller. Continue the loop,
// break the loop or return.
... add code here
}
bs = append(bs, b)
}
- 1 回答
- 0 關(guān)注
- 116 瀏覽
添加回答
舉報(bào)