The structure generated by protoc has some strange fields. Will it report an error if it is directly stored in MySQL?

< H1 > question < / H1 >

Message user is like this

message User {
    int32 uid = 1;
    string username = 2;
    string password = 3;
}
The go code generated by

looks like this:

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 directly use the above User to deposit MySQL will make an error, because XXX_NoUnkeyedLiteral these fields do not exist, there is a solution is that I manually change the generated code, ignore these fields , but I do not know how to do it?

Apr.01,2021

, of course, is to write a new structure.


the file generated by protoc is not recommended. I also asked on SO. It seems that we can only build a struct corresponding to table

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e4616e-443c7.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e4616e-443c7.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?