I\'m trying to learn Go API development. I have a MongoDB instance running in a Docker container. I\'m trying to follow a few guides but am failing on simple queries. I don\
You must export fields of structs, else they are ignored by the mgo
package. Change fields of users
to User
and Data
.
type users struct {
User string `bson:"user" json:"user"`
Data string `bson:"data" json:"data"`
}
By default when a struct value is transformed / stored / retrieved from MongoDB, the field name is used. If you want to use different names, you may use tags to tell what names should the fields map to.