-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Description
Apologies, I raised a similar ticket a while back but I just thought I'd raise a more specific question than my previous closed ticket. #393
For some context, when you generate protobuf code, say...
message Hello {
string id = 1;
}
You would get
type Hello struct {
Id string
}Which means I have to do a bunch of conversion in order to use these structs as Mongodb models. As Mongodb's mgo driver requires a bson.ObjectId custom type for the ID field. Also the ID field is all uppercase as per Golang's own linting/style guide. Whereas protobuf generates them as Id.
So given that, is there a way I can create a custom type which would generate mgo compatible ID fields? Such as...
message Hello {
BsonID id = 1;
}
generates...
type Hello struct {
ID bson.ObjectId
}I just wondered how to go about creating a custom type for this use-case?
I noticed someone had a PR of a similar nature a while back which wasn't approved/merged: #320
Thanks in advance!