Home > Back-end >  Running protoc commands not generating Register method
Running protoc commands not generating Register method

Time:02-19

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

CodePudding user response:

If you see the docs closely it mentions two things to be installed

$ go install google.golang.org/protobuf/cmd/[email protected]
$ go install google.golang.org/grpc/cmd/[email protected]

For second command you need go install google.golang.org/grpc/cmd/[email protected]

to be installed too.

For more look here

https://pkg.go.dev/google.golang.org/grpc/cmd/protoc-gen-go-grpc#section-readme

  • Related