Liam0205 / liam0205.github.io

Deployment of my weblog.
https://liam0205.github.io
34 stars 5 forks source link

利用 Protobuf 中 oneof 的特性生成 has_xxx 接口 | 始终 #350

Open Liam0205 opened 4 years ago

Liam0205 commented 4 years ago

https://liam.page/2020/05/05/using-oneof-to-generate-has-xxx-in-pb3/

Protobuf(全称 Protocal Buffer,简称 pb)是 Google 开源的序列化/反序列化工具,在工业界相当流行。pb3 相比 pb2 的一个显著变化,就是在 pb3 当中不再区分 required 和 optional 字段。与此同时,在 pb2 中针对 optional 基本类型字段设计的 [default = foobar] 的默认值功能和 has_xxx() 的借口也随之

BigBenSure commented 4 years ago

勘误:第一段,接口不是借口

Liam0205 commented 4 years ago

勘误:第一段,接口不是借口

谢谢,已修复~

BigBenSure commented 4 years ago

还有文档未注明的特性下面那行:“正是”不是“正式”~

Liam0205 commented 4 years ago

@BigBenSure 还有文档未注明的特性下面那行:“正是”不是“正式”~

您这个真是火眼金睛~

已修复~

ChasenYang commented 3 years ago

第二种方法里,使用的pb是哪个版本?我在使用 libprotoc 3.4.0 时, oneof 定义时报错:

  oneof bar {
    int32 bar = 2;
  }
"bar" is already defined in