gomongo Unmarshal issues with types that contain slices

There’s been an issue with the gomongo that I’ve been aware of for a while and I’ve just found a fix for it.

If you were to take the example that I created here:-
- http://go.hokapoka.com/golang/mongodb-golang-gomongo/

Which contains the following structs

type ExampleDoc struct {
   Title  string
   Body string
   Comments []Comment
}

type Comment struct{
   Author string
   Web string
   Message string
}

Upon Unmarshalling the ExampleDoc it’s Comments property has Len() = 0. I didn’t have any spare time to fix the issue but the other week I posted the issue on the Go-Nuts group and, being such a fantastic group, I had a response in no time.

With great thanks to Daniel Smith who created a gomongo fix some moths back that’s available on bitbucket.org.

I’ve not had the chance to find & merge the fix into the master as yet but it works a treat.

This entry was posted in golang, mondoDB. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>