I have a relatively complex structure that when I execute the mgo query, nothing (but defaults) fill my struct.
For example:
type MyStruct {
Verified string `json:"DigitalSignature"`
Immutable ImmutableValues `json:"Immutable"`
Mutable Mutable 'json:"Mutable"`
}
// values that cannot be changed
type Immutable struct {
Organization string `json:"Organization" bson:"Organization"`
...
}
type Mutable struct {
Settings AppSettings
OtherStuff OtherStuff
}
type Settings struct {
EnableUpdates bool `json:"EnableUpdates" bson:"EnableUpdates"`
...
}
When I issue a mongo select statement (i.e., "Organization":"xyz") I can see the record is returned, but populating a struct only gives the default values, e.g.
...
var orgData MyStruct
err := mongoSession.DB("myDB").C("collection").Find(bson.M{"Organization":"xyz"}).One(&orgData)
... convert to json (MarshalIndent()..)
fmt.Println(string(bytes)) <-- only see the default struct values
To verify that I;m finding the record, I changed this:
var orgData interface{}
...
Now printing shows all the correct record values.
So obviously there is a mapping issue going on between my struct definitions and what is being returned - what is the best way to determine what s happening under the hood (a debugger here would be nice :-) )