I'm trying to understand how to collect data from mongodb using Go. I created a sample database and filled it with one "person" with id, login, and password data fields. Here's my struct
type Person struct {
id bson.ObjectId `json:"id" bson:"_id"`
login string `json:"login" bson:"login"`
pass string `json:"pass" bson:"pass"`}
On the mgo documentation, the &data object says to be a interface{} type. I have it defined as a Person struct, yet it still compiles.
data := Person{}
c.Find(bson.M{"login": "Larry"}).One(&data)
fmt.Printf("(%v)\n", data.pass)
When I run the code, it prints: ()
Not sure what I'm doing wrong. If it should be an interface{} type, how could I format that Person interface?