1

I am trying to generate Go source code from .proto file through this command:

protoc greet/greetpb/greet.proto --go-grpc_out=plugins=grpc:.

and, this is the directory structure:

greet/greetpb/greet.proto

I have tried all the answers mentioned here But, none of them seems to be working.

I have verified that protoc-gen-go is in PATH. Still, I am getting this:

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.

Additional details:

Go Version: go version go1.14.6 darwin/amd64
protoc version: libprotoc 3.12.3

My .zshrc file:

export GOROOT=/usr/local/go
export GOPATH=$HOME/go
export GOBIN=$GOPATH/bin
export PATH=$PATH:$GOROOT:$GOPATH:$GOBIN
Aditya
  • 551
  • 5
  • 26
  • Try to add the option `-I=. -I=$GOPATH/src`. `-I` Specify the directory in which to search for imports. – Roman Kiselenko Aug 03 '20 at 07:34
  • I tried this ```protoc -I=. -I=absolute/path/to/dir/containting/proto/ greet/greetpb/greet.proto --go-grpc_out=plugins=grpc:.```, still getting the same error @Зелёный What are imports here? – Aditya Aug 03 '20 at 07:41
  • 2
    You can try this command `go install google.golang.org/grpc/cmd/protoc-gen-go-grpc` and set `--go-grpc_out=.` – Roman Kiselenko Aug 03 '20 at 07:45
  • _/\\_ this worked! Would you mind explaining the difference between the two commands? – Aditya Aug 03 '20 at 07:47
  • To be honest I dont know, the `out` suffix looks like an option for the output path in this case the current directory `.`. – Roman Kiselenko Aug 03 '20 at 07:51
  • The `protoc-gen-go` and `protoc-gen-go-grpc` are two different `protoc` plugins. While the former generates Go code for protobuf message definitions, the latter generates Go code for service definitions. – Easwar Swaminathan Aug 07 '20 at 22:42

0 Answers0