What may be happening is you’re using structs that contain fields that are mgobson.ObjectId type but using the mongo-go-driver BSON marshaler (inserting structs using the mongo-go-driver marshals the struct data as BSON). Because the mgobson.ObjectId type is an alias of string, the bson.ObjectId fields are being marshaled as string.
If my assumption about your use case is correct, you should replace the bson.ObjectId type with primitive.ObjectID from the "go.mongodb.org/mongo-driver/bson/primitive" package and see if that resolves the issue.
E.g.
type Default struct {
ID primitive.ObjectID `bson:"_id" json:"id"`
UserID primitive.ObjectID `bson:"user_id" json:"user_id"`
}
Can you share a code snippet of how you’re using instances of the Default struct with the mongo-go-driver so I understand your use case better?