windows下grpc+protobuf编译

290 阅读1分钟

1、protoc.exe文件下载

 下载地址:
 https://github.com/protocolbuffers/protobuf/releases/download/v21.9/protoc-21.9-win64.zip
    
将protoc.exe移动到gopath/bin路径下

2、编译生成可执行exe文件

分别下载

https://codeload.github.com/golang/protobuf/zip/refs/heads/master
https://codeload.github.com/grpc/grpc-go/zip/refs/tags/v1.50.0

protoc-gen-go-grpc.exe生成:

路径: grpc-go-1.50.0/cmd/protoc-gen-go-grpc
执行:CGO_ENABLED=1 GOOS=windows GOARCH=amd64 go install
执行完后会再gopaht/bin路径下生成protoc-gen-go-grpc.exe

protoc-gen-go.exe生成:

路径:protobuf/protoc-gen-go/
执行:CGO_ENABLED=1 GOOS=windows GOARCH=amd64 go install