1,安装protoc
brew tap homebrew/versions brew install protobuf go get code.google.com/p/goprotobuf/{proto,protoc-gen-go} go install code.google.com/p/goprotobuf/protoc-gen-go cd ~/golang/bin sudo cp protoc-gen-go /usr/local/bin/
2,生成ping.proto文件
package protocols; //心跳包 message Ping { required bool ping = 1; required int64 timestamp = 2;//时间戳 }
3,生成go文件
protoc --go_out=. ping.proto
有疑问加站长微信联系(非本文作者)