Zephus 发表于 2022-3-10 08:50

Golang Protobuf

1、安装protobuf brew install protobuf2、检查安装结果 protoc--version3、安装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 install4、运用,在文件目录里运行 4.1、编译protobuf 文件为项目文件: protoc --go_out=. *.proto 4.1、编译单个文件 protoc message.proto --go_out=/Users/saeipi/Desktop/msgexport GOPATH=$HOME/go       # gopath 设置路径 export GOBIN=$GOPATH/bin   # gobin路径export PATH="$GOBIN:$PATH"message.protosyntax ="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; }
页: [1]
查看完整版本: Golang Protobuf