Having looked at the Parse func that is called when an object is
unmarshalled it appears that something odd is happening.
Here :
https://github.com/mikejs/gomongo/blob/master/mongo/bson.go#L439
For each iteration through the Parse method I'm added
fmt.Println( "Processing : " + name + cval ) to the end.
The variable cval is only is an empty string unless the kind that is
being processed is StringKind, if this is the case cval has the
following assigned to it :
cval = " -- String value : " + string(s)
The following document has been inserted into the
doc := &Example{
Prop1 : "Value 1",
Prop2 : "Value 2",
Prop3 : []string{
"Value 3 a",
"Value 3 b",
"Value 3 c",
"Value 3 d",
},
}
This is what's rendered when the object is Unmarshalled :
Processing : id_
Processing : prop1 -- String value : Value 1
Processing : prop2 -- String value : Value 2
Processing : 0 -- String value : Value 3 a
Processing : 1 -- String value : Value 3 b
Processing : 2 -- String value : Value 3 c
Processing : 3 -- String value : Value 3 d
Processing : prop3 -- String value : Value 2
Processing : prop1 -- String value : Value 1
Processing : prop2 -- String value : Value 2
Processing : 0 -- String value : Value 3 a
Processing : 1 -- String value : Value 3 b
Processing : 2 -- String value : Value 3 c
Processing : 3 -- String value : Value 3 d
Processing : prop3 -- String value : Value 2
Processing : id_ -- String value : Value 2
I don't quite understand why it runs through all of the properties
twice.
However, that aside, there appears to be a clear issue with prop3, the
[]string. It appears to think it's a StringKind and it's assigning
the string "Value2" to it.
Although it's supposed to contain the collection of strings, that you
can see are indeed being extracted with their correct indexes.