Mac 安装使用protobuf

【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


    推荐阅读