多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
### 4.3 protobuf环境安装 ##### A\) protobuf 编译工具安装 1、下载 protoBuf: ```bash cd $GOPATH/src/ git clone https://github.com/protocolbuffers/protobuf.git ``` 2、或者直接将压缩包拖入后解压 ```bash unzip protobuf.zip ``` 3、安装依赖库 ```bash sudo apt-get install autoconf automake libtool curl make g++ unzip libffi-dev -y ``` 4、进入目录 ```bash cd protobuf/ ``` 5、自动生成configure配置文件: ```bash ./autogen.sh ``` 6、配置环境: ```bash ./configure ``` 7、编译源代码\(时间比较长\): ```bash make ``` 8、安装 ```bash sudo make install ``` 9、刷新共享库 (很重要的一步啊) ```bash sudo ldconfig ``` 10、成功后需要使用命令测试 ```bash protoc -h ``` ##### B\) protobuf 的 go 语言插件安装 由于protobuf并没直接支持go语言需要我们手动安装相关插件 1. 获取 proto包\(Go语言的proto API接口\) ```bash go get -v -u github.com/golang/protobuf/proto go get -v -u github.com/golang/protobuf/protoc-gen-go ``` 2. 编译 ```bash cd $GOPATH/src/github.com/golang/protobuf/protoc-gen-go/ go build ``` 3. 将生成的 protoc-gen-go可执行文件,放在/bin目录下 ```bash sudo cp protoc-gen-go /bin/ ```