安装
brew install protobuf
>> go get -u github.com/golang/protobuf/proto
>> go get -u github.com/golang/protobuf/protoc-gen-go
定义一个proto文件
syntax = "proto2";
package models;
message Message{
enum Type {
TEXT = 0;
TEXT2 = 1;
}
optional Type type = 1 [default = TEXT];
optional string source = 2 [default = ""];
}
命令生成库
protoc --go_out=. message.proto