Field with customized format string

17 views
Skip to first unread message

Yaroslav Molochko

unread,
Jul 3, 2019, 9:10:57 PM7/3/19
to Protocol Buffers
Hello,

I'm trying to use protobuf as an interface for our storage layer. Idea is to get RPC and execute some SQL/NoSQL code based on configuration. I'm trying to use gorm.io for SQL like databases.

I have proto file with message definition:
message Token {
   
string uuid = 1;
...
}

This got generated into Go code:

type
Token struct {
   
Uuid                 string    `protobuf:"bytes,1,opt,name=uuid,proto3" json:"uuid,omitempty"`
...
}

How can I extend the formatting string for the fields and add some extra information, not related to protobufor or json, and add gorm: "primary_key" to the field, e.g.:

type Token struct {
   
Uuid                 string    `protobuf:"bytes,1,opt,name=uuid,proto3" json:"uuid,omitempty" gorm:"primary_key"`
....
}

Is this even possible to change the generated code?
Thank you in advance!
Reply all
Reply to author
Forward
0 new messages