由 grpc proto3 生成的 protobuff 中的蛇形格样式
snake case style in protobuff generated by grpc proto3
是否可以在 grpc 中将 proto3
的默认模型从 CamelCase 更改为 snake_case?
示例:
文件anyproto.proto
...
message Request {
bool RequestStatus = 1;
string RequestMessage = 2
}
...
现在 protoc -I. --go_out=plugins=grpc:. anyproto.proto
命令生成此模型:
文件:anyproto.pb.go
type Request struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
RequestStatus bool `protobuf:"varint,1,opt,name=requestStatus,proto3" json:"requestStatus,omitempty"`
RequestMessage string `protobuf:"bytes,2,opt,name=requestMessage,proto3" json:"requestMessage,omitempty"`
}
我想将 requestStatus
和 requestMessage
的样式更改为 request_status
和 request_message
这是您要找的吗?
https://developers.google.com/protocol-buffers/docs/style#message_and_field_names
引自 link:
Use CamelCase (with an initial capital) for message names – for example, SongServerRequest. Use underscore_separated_names for field names (including oneof field and extension names) – for example, song_name.
message SongServerRequest {
required string song_name = 1;
}
是否可以在 grpc 中将 proto3
的默认模型从 CamelCase 更改为 snake_case?
示例:
文件anyproto.proto
...
message Request {
bool RequestStatus = 1;
string RequestMessage = 2
}
...
现在 protoc -I. --go_out=plugins=grpc:. anyproto.proto
命令生成此模型:
文件:anyproto.pb.go
type Request struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
RequestStatus bool `protobuf:"varint,1,opt,name=requestStatus,proto3" json:"requestStatus,omitempty"`
RequestMessage string `protobuf:"bytes,2,opt,name=requestMessage,proto3" json:"requestMessage,omitempty"`
}
我想将 requestStatus
和 requestMessage
的样式更改为 request_status
和 request_message
这是您要找的吗?
https://developers.google.com/protocol-buffers/docs/style#message_and_field_names
引自 link:
Use CamelCase (with an initial capital) for message names – for example, SongServerRequest. Use underscore_separated_names for field names (including oneof field and extension names) – for example, song_name.
message SongServerRequest {
required string song_name = 1;
}