bson.M
is a map[string]interface{}
(http://godoc.org/labix.org/v2/mgo/bson#M)
So, in
conditions["publishdate"]["$gte"] = fromDate.Unix()
You need to do a type assertion from interface{}
to bson.M
when looking up publishdate
in the map.
Instead, you could refactor the code to something like
publishdate:= bson.M{}
// ... your logic goes here
conditions["publishdate"] = publishDate
to save on unnecessary map lookups and type assertions.