How to construct an $or query in mgo
I am trying to convert this JS MongoDB query into Go mgo query: var foo = "bar"; db.collection.find({"$or": [ {uuid: foo}, {name: foo} ] }); This is what I've got so far, but it doesn't work: conditions := bson.M{"$or": []bson.M{bson.M{"uuid": name}, bson.M{"name": name}}} EDIT: It does seem to work now. Maybe I had a typo somewhere. Here is a complete example which works fine for me (with Go 1.4, and MongoDB 2.6.5) package main import ( "fmt" "log" "gopkg.in/mgo.v2" "gopkg.in/mgo.v2/bson" ) type Person struct { Num int Uuid string Name string } func main() { // Connect to the database session