I have a struct like this:
type ArticleDocument struct {
ArticleID string `json:"article_id" bson:"article_id"`
ArticleTitle string `json:"article_title" bson:"article_title"`
Author string `json:"author" bson:"author"`
Board string `json:"board" bson:"board"`
Content string `json:"content" bson:"content"`
Date string `json:"date" bson:"date"`
IP string `json:"ip" bson:"ip"`
MessageConut struct {
All int `json:"all" bson:"all"`
Boo int `json:"boo" bson:"boo"`
Count int `json:"count" bson:"count"`
Neutral int `json:"neutral" bson:"neutral"`
Push int `json:"push" bson:"push"`
} `json:"message_count,inline" bson:"message_count,inline"`
Messages []interface{} `json:"messages" bson:"messages"`
URL string `json:"url" bson:"url"`
}
In MongoDB, my document looks like:
{
"_id" : ObjectId("5ab1da8133691b034b2be31d"),
"article_id" : "M.1521548086.A.DCA",
"article_title" : "some title",
"author" : "somebody",
"board" : "some board",
"content" : "some content",
"date" : "Tue Mar 20 20:14:42 2018",
"ip" : "1.1.1.1",
"message_conut" : {
"all" : 15,
"boo" : 0,
"count" : 14,
"neutral" : 1,
"push" : 14
},
"messages" : [],
"url" : "https://xxx.xxx.xxx"
}
In my Golang code, i am trying to use mgo to query this document and print it out, however, all document fields are converted to golang struct correctly except the nested document "MessageConut", all the values in "All", "Boo", "Count", ...etc are zero:
message_count":{"all":0,"boo":0,"count":0,"neutral":0,"push":0}"
Could you please guide how do I solve this issue?