deepin 安装golang protobuf

1、安装库文件protobuf,地址:https://github.com/protocolbuffers/protobuf/releases

我电脑是deepin 64位的,所以我直接下载https://github.com/protocolbuffers/protobuf/releases/download/v3.9.1/protoc-3.9.1-linux-x86_64.zip

$wget https://github.com/protocolbuffers/protobuf/releases/download/v3.9.1/protoc-3.9.1-linux-x86_64.zip
$mkdir protoc
$cd protoc
$unzip protoc-3.9.1-linux-x86_64.zip
$cd bin
$cp protoc /home/dongge/go-work/bin/#复制到$GOPATH/bin目录下
$protoc --version

2、安装插件

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

gogoprotobuf有两个插件可以使用

  • protoc-gen-gogo:和protoc-gen-go生成的文件差不多,性能也几乎一样(稍微快一点点)

  • protoc-gen-gofast:生成的文件更复杂,性能也更高(快5-7倍)

//gogo
$go get github.com/gogo/protobuf/protoc-gen-gogo
//gofast
$go get github.com/gogo/protobuf/protoc-gen-gofast

3、安装gogoprotobuf库文件

$go get github.com/gogo/protobuf/proto
$go get github.com/gogo/protobuf/gogoproto  //这个不装也没关系

4、生成go文件

//gogo
$protoc --gogo_out=. *.proto

//gofast
$protoc --gofast_out=. *.proto

 






转载于:https://www.cnblogs.com/Dong-Ge/p/11463386.html

你可能感兴趣的:(deepin 安装golang protobuf)