一般使用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;
}
 
 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-08
  • 2021-12-10
  • 2022-12-23
  • 2021-12-26
  • 2022-01-18
猜你喜欢
  • 2021-10-11
  • 2021-12-27
  • 2022-12-23
  • 2021-11-05
  • 2021-12-03
  • 2021-08-26
相关资源
相似解决方案