Cannot retrieve “_id” value using mgo with golang
This is my struct definition: type Article struct { Id bson.ObjectId `json:"id" bson:"_id,omitempty"` Title string `json:"title"` Author string `json:"author"` Date string `json:"date"` Tags string `json:"tags"` Content string `json:"content"` Status string `json:"status"` } This is the method I get my data from database: func AllArticles() []Article { articles := []Article{} err := c_articles.Find(bson.M{}).All(&articles) if err != nil { panic(err) } return articles } This is one piece of object stored in database: { "_id" : ObjectId( "5281b83afbb7f35cb62d0834" ), "title" : "Hello1", "author"