我有一個結構 -
type User struct {
Uid string `firestore:"uid"`
FcmToken string `firestore:"fcmtoken"
}
我如何使用 將它轉換為映射 json.Marshal(user),我知道可以在用 struct 欄位注釋時完成,json:"fieldname"但我不知道在用 firestore 注釋時如何做,或者甚至可能嗎?
我用了annotation這個詞,可能不是它的名字,請指正!
uj5u.com熱心網友回復:
一個欄位標簽可以包含多個鍵/值對。有關更多詳細資訊,請參閱結構標記檔案。
編輯欄位標簽以包含您想要的任何 JSON 配置:
type User struct {
Uid string `firestore:"uid" json:"uid"`
FcmToken string `firestore:"fcmtoken" json:"tid"`
}
無法讓 JSON 包使用 firestore 標簽,反之亦然。
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/353978.html
標籤:json 走 谷歌云firestore
