'--go-grpc_out: protoc-gen-go-grpc: Plugin failed with status code 1

i am getting this error when i compile my proto file:

protoc-gen-go-grpc: program not found or is not executable
Please specify a program using absolute path or make sure the program is available in your PATH system variable
\--go-grpc_out: protoc-gen-go-grpc: Plugin failed with status code 1.

I am using these versions:

Binary Version
protoc-gen-go v1.25.0-devel
protoc v3.12.4

I have tried to compile this proto file:

syntax = "proto3";

option go_package = "proto/";

message GreetingRequest {
  string first_name = 1;
  string last_name = 2;
}
message GreetingResponse{
  string result = 1;
}

service AddService{
  rpc Greet(GreetingRequest) returns (GreetingResponse) {};
}

I used this command:

protoc \
--proto_path=proto \
--go_out=proto \
--go_opt=paths=source_relative \
--go-grpc_out=proto \
--go-grpc_opt=paths=source_relative \
service.proto

I installed protoc-gen-go-grpc using:

go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest

but its still showing this error.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source