Added support for marshaling/unmarshaling of MongoDB's BSON UUID binary format#92
Added support for marshaling/unmarshaling of MongoDB's BSON UUID binary format#92inliquid wants to merge 2 commits intosatori:masterfrom inliquid:master
Conversation
…marshaling in MongoDB's BSON binary UUID format with Legacy UUID as default kind (0x03). - Introduced SetBSONKind function to make user able to set different BSON kind.
- Comments changed accordingly
|
I would disagree regarding this pr since there are different libraries for handling BSON format (eg mongo-go-driver and mgo) so it's better to have this implementation outside the package scope EDIT: You can find a solution to this problem on the following stackoverflow link |
|
@saniales the above stackoverflow link covers different and quite too much particular case (it's close but not the same, also please pay attention that proposed solution covers both Mongo's Legacy UUID and new UUID binary kinds). And yes of course it's possible to embed UUID into your own struct and write Marshaler/Unmarshaler for that struct. However, if you try to do so you'll find that code becomes more complex, less clear, and overall it seems strange when support for JSON comes out of the box, but for BSON you have to reinvent the wheel. In my project I did this trick with embedded struct initially, but later moved to forked version of UUID implementation. From the other hand, I understand concerns for external dependencies. |
Added support for marshaling/unmarshaling of MongoDB's BSON UUID binary format.