deepin 安装golang protobuf

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

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

$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

二、安装插件github

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

gogoprotobuf有两个插件能够使用golang

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

  • 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

三、安装gogoprotobuf库文件spa

$go get github.com/gogo/protobuf/proto
$go get github.com/gogo/protobuf/gogoproto  //这个不装也不要紧

四、生成go文件插件

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

//gofast
$protoc --gofast_out=. *.proto
相关文章
相关标签/搜索