How to store a UUID in MongoDB with Golang?

Due to the nature of UUID type being an alias of [16]byte, Mongo will resort to storing it as a BSON Binary of subtype 0x00. It is impractical to attempt to convert the UUID to a base64 binary format for BSON. So you may choose to use this encoder & decoder feature I wrote that can be plugged directly into the mongo client struct here:

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top