cannot use Handler ... as type grpc.methodHandler in field value

22 views
Skip to first unread message

1306

unread,
Nov 30, 2017, 1:36:35 PM11/30/17
to grpc.io
After protoc generated the .pb.go file from my .proto file, I'm having issues building my client/server Go programs due to the following error:

cannot use _<Service>_<RPC-function>_Handler (type func(interface {}, "context".Context, grpc.Codec, []byte) (interface {}, error)) as type grpc.methodHandler in field value

I've tried to follow the steps listed in:
1 - https://stackoverflow.com/questions/33506221/how-to-fix-this-issue-with-grpc-method-handler/35789518#35789518
2 - https://github.com/grpc/grpc-go/issues/656
and also asked on gophers slack channel about the steps I've taken to solve the issue:
a) `rm -rf $GOPATH/src/github.com/grpc` and `rm -rf $GOPATH/bin/protoc-gen-go` and the same for `$GOPATH/src/github.com/golang/protobuf`
b) `go get -u ...protobuf` and `go get -u ...grpc`
c) `cd $GOPATH/src/.../protobuf/` and `make`
d) `rm file.pb.go` and `protoc ... file.proto`
e) `rm $GOPATH/src/myrepo/project/pb`
f) `git cm` and `git push` new pb.go to myrepo
g) `go get -u myrepo/project/pb` where I get the first `:cannot use ... as type grpc.methodHandler in field value` error
h) `go build src/client/main.go` where I get the second `:cannot use ...as type grpc.methodHandler in field value` error
i'm sure there's something that i'm still doing wrong...

I'd appreciate if anyone can suggest what I'm doing wrong or any hints in the right direction.

Thanks!

Doug Fawley

unread,
Dec 6, 2017, 4:43:20 PM12/6/17
to grpc.io
What was the protoc command you used to generate the pb.go file?  It should look something like this: protoc --go_out=plugins=grpc:. *.proto

If that doesn't work, I may need to see something more concrete (e.g. your actual .pb.go file; names redacted if necessary) to help.  Can you file an issue in https://github.com/grpc/grpc-go in that case?

Thanks,
Doug
Reply all
Reply to author
Forward
0 new messages