环境 mac os 10.14.2
1 先下载protoc https://github.com/protocolbuffers/protobuf/releases/tag/v3.6.1
解压
2 复制到 /usr/local/下
3 chmod -R 777 /usr/local/protoc-3.13.0-osx-x86_64 修改权限
4 建立软链接 ln -s /usr/local/protoc-3.13.0-osx-x86_64 /usr/local/protoc
5 修改环境变量
cd ~
vi .bash_profile
修改
export PROTOC=/usr/local/protoc/bin
export GOROOT=/usr/local/go
export PATH=$PATH:/usr/local/mysql/bin:$PROTOC
生效 source .bash_profile
6 测试
7 下载 protoc-gen-go
go get -u github.com/golang/protobuf/protoc-gen-go
便可以在$GOPATH/bin目录下发现这个工具。
然后复制到 /usr/local/bin/目录下
8 git 下载代码 https://github.com/zhengzhihua2017/protocol_test