1、如何在window下,根據(jù)*.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版本,需要自己根據(jù)源碼生成
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