Installation
https://github.com/protocolbuffers/protobuf/blob/master/src/README.md
Proto
pb/entities.proto
: 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25syntax = "proto3";
package entities;
option go_package = "pb/entities";
enum Gender {
UNKNOWN = 0;
MALE = 1;
FEMALE = 2;
}
message Person {
Gender gender = 1;
string name = 2;
repeated string tags = 3;
double height = 4;
int32 age = 5;
oneof important {
string task = 6;
int32 problem = 7;
double point = 8;
}
map<string, string> extra = 10;
}
Golang
https://developers.google.com/protocol-buffers/docs/gotutorial
$ protoc --proto_path=./ --go_out=./ pb/entities.proto
1 | package main |
Python
https://developers.google.com/protocol-buffers/docs/pythontutorial
$ protoc --proto_path=./ --python_out=../python pb/entities.proto
1 | # coding: utf-8 |