refs:
https://cxwangyi.wordpress.com/2012/04/13/mastering-google-protocol-buffer-custom-option-with-repeated-fields/
使用protobuf时 发现repeat和optional不能同时使用,参考refs后有了workaround方法。
We encountered a question about Google protocol buffer: could we create a custom option which has a repeated decoration?
The protocol buffer compiler, protoc, answers: no.
However, it is OK to create an option with a message type, and the message could contain a repeated field. Here follows an example program.
The content of learn.proto:
import "google/protobuf/descriptor.proto";
message Something {
repeated int32 a = 1;
}
extend google.protobuf.FieldOptions {
optional float my_field_option = 50002;
optional Something my_another_field_option = 50003;
}
message MyMessage {
optional string my_field = 1
[(my_field_option) = 1.1];
optional string my_another_field = 2
[(my_another_field_option) = { a : [111, 222, 333] } ];