简体   繁体   中英

getting Unimplemented name Error in generated go file from proto

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

错误图像

this is my.proto file:

原型文件

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

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

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

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 ).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM