Mac 安裝使用protobuf

1.使用brew安裝protoc

brew install protobuf

查看安裝結果

protoc --version

 

2.編輯protobuf文件

syntax = "proto3";

package message;

message OrderRequest {
  string orderId = 1;
  int64 timeStamp = 2;
}

message OrderInfo {
  string OrderId = 1;
  string OrderName = 2;
  string OrderStatus = 3;
}

3.生成go文件

protoc message.proto --go_out=/message/

如果提示

protoc-gen-go: program not found or is not executable
Please specify a program using absolute path or make sure the program is available in your PATH system variable
--go_out: protoc-gen-go: Plugin failed with status code 1.

執行命令:

go get -a github.com/golang/protobuf/protoc-gen-go

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章