Running protoc commands not generating Register method

Issue

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

Solution

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

Answered By – Shubh

Answer Checked By – Marie Seifert (GoLangFix Admin)

Leave a Reply

Your email address will not be published.