[Go] protobuffer 的环境配置
2023-02-18 15:41:07 时间
一般使用gprc是需要使用protobuf作为数据传输的格式标准,可以对要传输的对象结构体进行序列化
先安装protoc,找到对应版本,下载直接把二进制文件复制到环境变量可以访问到的地方就行
https://github.com/protocolbuffers/protobuf/releases
安装go的依赖包和工具
git clone https://github.com/grpc/grpc-go.git $GOPATH/src/google.golang.org/grpc
git clone https://github.com/golang/protobuf.git $GOPATH/src/github.com/golang/protobuf
go install github.com/golang/protobuf/protoc-gen-go
创建文件比如orders.proto,required必填 ,后面那个1和2是字段顺序
syntax = "proto2";
message Orders {
required int32 order_id=1;
required string title=2;
}
相关文章
- [Linux] 使用secureCRT实现SSH隧道服务器端口转发到本机内网穿透
- [Linux] 解决nginx: [emerg] directive "rewrite" is not terminated by ";"
- [Linux] PHP程序员玩转Linux系列-lnmp环境的搭建
- [Linux] PHP程序员玩转Linux系列-怎么安装使用
- [Go] gocron源码阅读-判断是否使用root用户执行
- [Go] 使用go mod安装beego
- [Linux] 使用openssl实现RSA非对称加密
- [Linux] ubuntu安装配置vsftpd并锁定目录
- [Go] tcp服务下的数据传递
- [Go] gocron源码阅读-go语言web框架Macaron
- [Go] gocron源码阅读-通过第三方cli包实现命令行参数获取和管理
- [Go] gocron源码阅读-flag包实现命令行参数获取
- [Go] gocron源码阅读-groutine与channel应用到信号捕获
- [Go] gocron源码阅读-空接口类型interface{}
- [Go] gocron源码阅读-go语言中的切片接口和类型综合
- [Go] gocron源码阅读-go语言中的切片和类型综合
- [Go] gocron源码阅读-go语言的结构体
- [Go] vscode配置Go环境
- [日常] gocron源码阅读-使用go mod管理依赖源码启动gocron
- [日常] gocron源码阅读-go语言的变量