You can use maps for that:
data, err := bson.Marshal(bson.M{"a": 1})
if err != nil {
panic(err)
}
var m bson.M
err = bson.Unmarshal(data, &m)
if err != nil {
panic(err)
}
println(m["a"].(int))
Note that bson.M is simply an alias for map[string]interface{}. You
can define the map type yourself if you wish to.
--
Gustavo Niemeyer
http://niemeyer.net
http://niemeyer.net/blog
http://niemeyer.net/twitter
Your email contains unreadable information. Either way, I think the
issue is most likely that you're passing corrupted data to gobson.
Most likely a partial document.
Ah, indeed.. you can't simply unmarshal things from the socket..
there's a protocol involved. You can find the source code for mgo
through the goinstall link itself: https://launchpad.net/mgo