But turns out that the java driver for MongoDB changes the order of the bytes in the uuid, so you need to reorder them in your go code:
//this is my doc in Mongo
var ext1 struct {
ID bson.Binary `bson:"_id"`
Expires time.Time
UserID bson.ObjectId `bson:"userId"`
CompanyID bson.ObjectId `bson:"companyId"`
}
//cookie.Value has the uuid as string generated by the Java driver
u, err := uuid.FromString(cookie.Value)
if err != nil {
fmt.Printf("Something gone wrong: %s\n\n", err)
}
//Here we match the order the java driver uses
var searchID []byte
for x := 7; x > -1; x-- {
searchID = append(searchID, u[x])
}
for x := 15; x > 7; x-- {
searchID = append(searchID, u[x])