找回密码
 立即注册
查看: 295|回复: 0

Golang Protobuf

[复制链接]
发表于 2022-3-10 08:50 | 显示全部楼层 |阅读模式
1、安装protobuf brew install protobuf  2、检查安装结果 protoc  --version  3、安装golang for protobuf插件 go get github.com/golang/protobuf/protoc-gen-go go get -u -v github.com/golang/protobuf/protoc-gen-go  或者 git clone https://github.com/golang/protobuf.git 目录下,分别进入到 protobuf/proto 和 protobuf/protoc-gen-go/ 目录下执行 go build go install  4、运用,在文件目录里运行 4.1、编译protobuf 文件为项目文件: protoc --go_out=. *.proto 4.1、编译单个文件 protoc message.proto --go_out=/Users/saeipi/Desktop/msg  export GOPATH=$HOME/go       # gopath 设置路径 export GOBIN=$GOPATH/bin     # gobin  路径  export PATH="$GOBIN:$PATH"  message.proto  syntax ="proto3"; package message; option go_package ="./";  message OrderRequest {   string orderId =1;   int64 timeStamp =2; }  message OrderInfo {   string OrderId =1;   string OrderName =2;   string OrderStatus =3; }
懒得打字嘛,点击右侧快捷回复 【右侧内容,后台自定义】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Unity开发者联盟 ( 粤ICP备20003399号 )

GMT+8, 2025-5-11 07:06 , Processed in 0.133987 second(s), 25 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2025 Discuz! Team.

快速回复 返回顶部 返回列表