英文:
Running protoc commands not generating Register method
问题
我正在尝试在grpc go中使用插件方法生成服务。
这是我的score.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
我知道插件标志已被弃用,但是如何同时生成插件还是有点困惑。任何帮助将不胜感激。
英文:
I am trying to generate service with plugin methods in for grpc go
This is my score.proto file
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;
}
When I am running this command
protoc -I=. --go_out=. score.proto
its working fine
But following command to generate RegisterScoreServiceServer
as well
protoc -I=. --go-grpc_out=. score.proto
is giving me error
protoc-gen-go-grpc: program not found or is not executable
I know the plugins flag is deprecated ,but then how to generate plugins as well .Its bit confusing any help would be welcome
答案1
得分: 1
如果你仔细查看文档,它提到需要安装两个东西:
$ 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-readme
英文:
If you see the docs closely it mentions two things to be installed
$ 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
For second command you need go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.1
to be installed too.
For more look here
https://pkg.go.dev/google.golang.org/grpc/cmd/protoc-gen-go-grpc#section-readme
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论