1. 下载protoc,添加到环境变量

下载地址:https://github.com/google/protobuf/releases,windows下选择protoc-3.6.1-win32.zip即可。

2. 下载安装Go插件protoc-gen-go

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

protoc-gen-go将被安装到$GOBIN中(默认为$GOPATH/bin),需要将该路径添加到环境变量$PATH中。

3. 制定协议,编写x.proto文件

 参考https://www.cnblogs.com/xiaochuizi/p/9468006.html

4. 根据x.proto文件生成go语言的marshaling/demarshaling代码x.pb.go

protoc --go_out=. x.proto

相关文章:

  • 2021-07-05
  • 2022-12-23
  • 2022-12-23
  • 2021-07-16
  • 2021-12-12
  • 2021-09-19
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-12-20
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-02
相关资源
相似解决方案