xxxxxxxxxx
syntax="proto3"
message Person {
required int32 id = 1;
required string name = 2;
optional string email = 3;
}
xxxxxxxxxx
syntax="proto3"
message Person {
required int32 id = 1;
required string name = 2;
optional string email = 3;
}
xxxxxxxxxx
syntax = "proto3";
package bookstore;
service BookService {
rpc GetBookInfo (BookRequest) returns (BookResponse);
}
message BookRequest {
string book_id = 1;
}
message BookResponse {
string title = 1;
string author = 2;
}
xxxxxxxxxx
python3 -m pip install protobuf==3.20.0 -i https://mirror.baidu.com/pypi/simple
xxxxxxxxxx
Protocol buffers are Google's language-neutral, platform-neutral, extensible mechanism for serializing structured data – think XML, but smaller, faster, and simpler. You define how you want your data to be structured once, then you can use special generated source code to easily write and read your structured data to and from a variety of data streams and using a variety of languages.
xxxxxxxxxx
VERSION="v3.4.1"
# Build and install proto3.
git clone https://github.com/google/protobuf.git
cd protobuf
git checkout tags/${VERSION}
mkdir build
cd build
cmake -G Ninja \
-DCMAKE_POSITION_INDEPENDENT_CODE=ON \
-DCMAKE_BUILD_TYPE=Release \
-Dprotobuf_BUILD_TESTS=OFF \
../cmake
ninja
sudo ninja install