gpt4 book ai didi

go - 由 grpc proto3 生成的 protobuff 中的蛇形格样式

转载 作者:行者123 更新时间:2023-12-01 21:09:39 58 4
gpt4 key购买 nike

是否可以将 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"`
}

我想将 requestStatusrequestMessage 的样式更改为 request_statusrequest_message

最佳答案

这是你要找的吗?
https://developers.google.com/protocol-buffers/docs/style#message_and_field_names
引用自链接:

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;
}

关于go - 由 grpc proto3 生成的 protobuff 中的蛇形格样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62873118/

58 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com