Defining this struct
type SymbolMCAddrPort struct {
ID bson.ObjectId `bson:"_id,omitempty"`
Symbol string
MCAddr string
MCPort int
}
session, err := mgo.Dial("10.0.0.61")
if err != nil {
panic(err)
}
defer session.Close()
csap := session.DB("FX").C("MCAddrPortPairs")
If I say
var resultsSMP bson.M
err = csap.Find(bson.M{"Symbol": "EUR/USD"}).One(&resultsSMP)
fmt.Println(resultsSMP)
I correctly see
map[_id:ObjectIdHex("56fc34e961fed32064e656b0") Symbol:EUR/USD MCAddr:239.0.0.222 MCPort:345]
But if I say
resultsSMP := SymbolMCAddrPort{}
err = csap.Find(bson.M{"Symbol": "EUR/USD"}).One(&resultsSMP)
if err != nil {
panic(err)
}
fmt.Println(resultsSMP)
I just see
{ObjectIdHex("56fc34e961fed32064e656b0") 0}
I note that the ID is correct, but I can't get the rest of the fields in the struct?