-
前提配置好Go环境
-
github.com/google/protobuf/releases 中下载对应操作系统的ProtoBuf安装包
-
Protobuf Runtime安装
-
$export GO111MODULE=on # Enable module mode
-
$go get github.com/golang/protobuf/protoc-gen-go #GOPATH的bin目录会生成protoc-gen-go.exe
-
配置GRPC $go get -u google.golang.org/grpc
-
获取示例demo $git clone -b v1.31.0 https://github.com/grpc/grpc-go
注意事项:
更新.proto文件后
$protoc
–go_out=Mgrpc/service_config/service_config.proto=/internal/proto/grpc_service_config:.
–go-grpc_out=Mgrpc/service_config/service_config.proto=/internal/proto/grpc_service_config:.
–go_opt=paths=source_relative
–go-grpc_opt=paths=source_relative
helloworld/helloworld.proto
这将重新生成helloworld/helloworld.pb.go和helloworld/helloworld_grpc.pb.go文件