如何在window 安装protoc protoc-gen-g

2020-09-21  本文已影响0人  码二哥

1、如何在window下,根据*.proto 生成代码么?

image

2、下载protoc

https://github.com/protocolbuffers/protobuf/releases/download/v3.12.3/protoc-3.12.3-win64.zip
解压后,放到$GOPATH/bin目录下即可

image

3、如何生成protoc-gen-go-grpc ?

目前在github上,还没有提供release版本,需要自己根据源码生成
https://www.grpc.io/docs/languages/go/quickstart/

git clone -b v1.30.0 https://github.com/grpc/grpc-go  
cd cmd/protoc-gen-go-grpc  
go install .
image

4、生成*.pb.go代码

protoc --plugin=protoc-gen-go=$protoc-gen-go的路径  --go_out .  helloworld.proto
image

5、如何生成*_grpc.pb.go

protoc --plugin=protoc-gen-go=$protoc-gen-go的路径  --go-grpc_out .  --go_out .  helloworld.proto
image
上一篇 下一篇

猜你喜欢

热点阅读