From the mgo
docs:
pipe := collection.Pipe([]bson.M{{"$match": bson.M{"name": "Otavio"}}})
Decomposing this statement, I see that the argument passed to collection.Pipe
is of type []bson.M
. Given that slices are initialized via []sometype{ ... }
syntax, I conclude that the aforementioned slice contains exactly one item (so len == 1
), and that this item is the {"$match": bson.M{"name": "Otavio"}}
literal.
What is the type of this literal? Intuitively, I want to say it's a map[string]interface{}
, but when I tried checking on the go playground, I'm unable to initialize a similar data structure: https://play.golang.org/p/7QKYaQPi6g
My question is therefore twofold:
- What is the type of
https://play.golang.org/p/7QKYaQPi6g
(assuming I've made no mistake in my reasoning) - What am I doing wrong in
x := {"foo": 1, "bar": 1}
?