go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest go install google.golang.org/protobuf/cmd/protoc-gen-go@latest go get google.golang.org/grpc
编写Proto代码
helloword/;golang:配置Proto代码存放位置和编译后的语言
helloword/helloword.proto
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
syntax = "proto3";
option go_package="helloword/;helloword";
package hello_grpc;
message Req { string message = 1; }
message Res { string message = 1; }
service HelloGRPC { rpc SayHi(Req) returns (Res); }