我正在尝试在grpc-go 中使用插件方法生成服务
这是我的分数.proto文件
syntax="proto3";
option go_package="./livescore";
service ScoreService{
rpc ListMatches(ListMatchesRequest) returns (ListMatchesResponse);
}
message ListMatchesRequest{
string country=1;
}
message MatchScoreResponse{
string score =1;
bool live=2;
}
message ListMatchesResponse{
repeated MatchScoreResponse scores=1;
}
当我运行这个命令
protoc -I=. --go_out=. score.proto
其工作良好的
但以下命令生成RegisterScoreServiceServer
以及
protoc -I=. --go-grpc_out=. score.proto
正在给我错误
protoc-gen-go-grpc: program not found or is not executable
我知道插件标志是不赞成的,但如何生成插件也是如此。它有点令人困惑,任何帮助都是受欢迎的
如果你仔细查看文档,它会提到两件事要安装
$ go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.26
$ go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.1
对于第二个命令,您需要go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.1
也要安装。
欲了解更多信息,请点击此处
https://pkg.go.dev/google.golang.org/grpc/cmd/protoc-gen-go-grpc#section-自述