I want to have an API to save a User. Here is my user message:
message User {
int32 uid = 1;
string username = 2;
string password = 3;
}
And I use protoc-gen-go
to convert it to go struct. I found some strange fields was added(XXX_NoUnkeyedLiteral
, XXX_unrecognized
).
type User struct {
Uid int32 `protobuf:"varint,1,opt,name=uid,proto3" json:"uid,omitempty"`
Username string `protobuf:"bytes,2,opt,name=username,proto3" json:"username,omitempty"`
Password string `protobuf:"bytes,3,opt,name=password,proto3" json:"password,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
I can't save it to MySQL due to those fields because my MySQL table doesn't have those fields. anyone good advice? I have to create another struct to convert MySQL table to protobuf Message?