If I generate a new object id for a document in mgo:
obId := bson.NewObjectId()
and then insert it, it ends up in mongo (looking via the cli) as
"_id" : "U�`�\u0006@�U\u0000\u0000\u0001"
When it should be
"_id" : ObjectId("559a47643d9827f0d9405420")
Same goes if I try and update an existing document where I generate the id by
obId := bson.ObjectIdHex(stringId)
It still gets serialized to the corrupted format.
My struct which I'm trying to insert looks like this:
type MyStruct struct {
Id bson.ObjectId `bson:"_id,omitempty" json:"id"`
...
}