0
votes

newbie here.

Currently learning how grpc works and was going through the tutorial in this link
https://grpc.io/docs/quickstart/go.html#update-and-run-the-application

When I ran the example using the helloworld.pb.go file provided, it works. But when I deleted that file and ran protoc --go_out=plugins=grpc:. *.proto to generate the that file again, I find that I can no longer run the greeter server.

The error I am getting is

google.golang.org/grpc/examples/helloworld/helloworld helloworld/helloworld.pb.go:105:11: cannot use _Greeter_SayHello_Handler (type func(interface {}, "context".Context, grpc.Codec, []byte) (interface {}, error)) as type grpc.methodHandler in field value

Tried to google but couldn't find out why. My protobuf version is 3.5.1 and the grpc is freshly cloned from github.com/golang/protobuf/protoc-gen-go

1
Do you have a different version of go grpc library vendored?Thomas
Maybe try updating both proto plugins: go get -u github.com/golang/protobuf/{proto,protoc-gen-go}?menghanl
I updated both and it still doesnt work...Eric
I would download the example again and have a look at the method signature for _Greeter_SayHello_Handler .Generate the file again using the protoc command. If the signature is different then your protoc-gen-go is mismatched. Delete any binary protoc in your $PATH and install again.kdvy

1 Answers

0
votes

Generate proto like this

file_name : Your proto file name with the path

//To generate the grpc code 
protoc proto/file_name.proto --go_out=plugins=grpc:.

Take a look this link How to write proto and generate the proto file. It may help your problem

https://github.com/SXerox007/protos-