Golang protobuf v2 issues with grpc

703 views
Skip to first unread message

KS Chow

unread,
Feb 10, 2021, 6:51:43 AM2/10/21
to grpc.io
New to protobuf and grpc, was trying the grpc Quick start tutorial.
I installed latest Go (1.15.8) and protobuf (v 3.14.0).

Then I installed protobuf compiler via:

I am able to compile my test.proto to get test.pb.go and test_grpc.pb.go via:
protoc --go_out=. --go-grpc_out=. test.proto

But compiling my sample code I get errors i.e.

grpc is trying to import "github.com/golang/protobuf/proto" which doesnt exist, it should be pointing to google.golang.org/protobuf/proto

Any idea how to get grpc to point to protobuf v2? Or I need to switch to protobuf v1 (github.com/golang/protobuf) to work with grpc?

Easwar Swaminathan

unread,
Feb 10, 2021, 10:53:45 PM2/10/21
to grpc.io
gRPC-Go has a dependency on the old and new protobuf packages. See our go.mod file here: https://github.com/grpc/grpc-go/blob/master/go.mod

When you try running/compiling your example code for the first time, you should see both these dependencies being pulled down:
easwars@grpc-go:~/grpc-go/examples/helloworld$ go run greeter_server/main.go
go: downloading github.com/golang/protobuf v1.4.2
go: downloading google.golang.org/protobuf v1.25.0
go: downloading google.golang.org/genproto v0.0.0-20200806141610-86f49bd18e98
go: downloading golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a
go: downloading golang.org/x/net v0.0.0-20190311183353-d8887717615a
go: downloading golang.org/x/text v0.3.0
2021/02/11 03:49:57 Received: world

Please try going through the quickstart to see if you missed anything.

Thanks

Reply all
Reply to author
Forward
0 new messages