现在grpc基本上用的都是proto3, 官网 style guide
示例如下:
需要重点掌握slice和map的用法以及rpc的定义
syntax = "proto3";
option go_package="./;proto";
service Greeter {
rpc GetConfigFromVPS(Empty) returns (BMKConfig);
rpc SendConfigToVPS(stream BMKConfig) returns (Empty);
}
message BMKConfig {
repeated Brand brands = 1;
map<string,string> file_map = 2;
}
message Brand {
string short_name = 1;
string full_name = 2;
string color = 3;
}
message Empty {
}
Scalar Value Types
A scalar message field can have one of the following types – the table shows the type specified in the .proto file, and the corresponding type in the automatically generated class: