Home > Software design >  getting Unimplemented name Error in generated go file from proto
getting Unimplemented name Error in generated go file from proto

Time:03-20

Every time, I generate the code, I am getting this error:

error-image

this is my .proto file:

proto-file

the command that, I use to generate the code is:: 

protoc pb/pb.proto --go-grpc_out=./pb

CodePudding user response:

Please try this command to generate the code

protoc -I <proto-file-folder/> --go_out=plugins=grpc:<folder-to-store-generated-go-file> <proto-file-folder>/*.proto

In your case

protoc -I pb/ --go_out=plugins=grpc:pb/ pb/*.proto

CodePudding user response:

As per the tutorial you need to use pass protoc two parameters; --go_out and --go-grpc_out (you probably also want to pass the associated _opt parameters):

protoc --go_out=. --go_opt=paths=source_relative \
    --go-grpc_out=. --go-grpc_opt=paths=source_relative \
    routeguide/route_guide.proto

In your case this translates to:

protoc pb/pb.proto --go_out=./pb  --go-grpc_out=./pb

The reason for the error that you were seeing is that --go-grpc_out tells protoc to run protoc-gen-go-grpc (from google.golang.org/grpc/cmd/protoc-gen-go-grpc). This executable only generates the gRPC specific code; it assumes that the code required to translate between protoBuf and Go structures has already been created (and this is done by protoc-gen-go which is triggered by the --go_out).

  • Related