protobuf list
时间: 2023-09-21 10:12:20 浏览: 46
Protobuf (Protocol Buffers) is a language-agnostic binary serialization format developed by Google. It allows you to define a schema for structured data and generate code in various programming languages to serialize and deserialize the data.
In protobuf, you can use the "repeated" keyword to define a list or array of elements. Here's an example of how you can define a list in a protobuf message:
```protobuf
syntax = "proto3";
message MyMessage {
repeated int32 numbers = 1;
}
```
In this example, the `MyMessage` message has a field called `numbers`, which is defined as a repeated list of `int32` values. The "1" is the field number used for identification.
When you generate code from this protobuf definition, you can use the generated code to add, retrieve, and manipulate elements in the list.