思考(七十一):Protobuf oneof 实现消息分发

oneof

官方文档介绍: https://developers.google.com/protocol-buffers/docs/reference/go-generated#oneof

需要科学上网,所以直接摘录下内容,方便查阅:

Oneof Fields

For a oneof field, the protobuf compiler generates a single field with an interface type isMessageName_MyField. It also generates a struct >for each of the singular fields within the oneof. These all implement this isMessageName_MyField interface.

For this message with a oneof field:

package account;
message Profile {
 oneof avatar {
   string image_url = 1

猜你喜欢

转载自blog.csdn.net/u013272009/article/details/107462260