Skip to content

Latest commit

 

History

History
32 lines (21 loc) · 1.18 KB

README.md

File metadata and controls

32 lines (21 loc) · 1.18 KB

How to use go mod with gRPC

I followed the official "hello world" example code. But, I couldn't make it work with go mod easily.

The major problem was this line. It is likely that the API was removed etc.

In server/main.rs, comment this.
// pb.UnimplementedGreeterServer

I had to inspect what happend to "UnimplementedGreeterServer" by reading pb in helloworld/helloworld.pb.go. You can see that you can not find it there.

How to reproduce working code example.

$go mod init steadylearner.com/grpc
$go get github.com/golang/protobuf
$google.golang.org/grpc v1.28.0

Install what lack here if necessary. You can refer to the GitHub page for it.

Then, you can use this to build protobuf file.

protoc -I helloworld/ helloworld/helloworld.proto --go_out=plugins=grpc:helloworld

Everything is ready. First, run gRPC server with $go run main.rs in current folder. Then, $cd client && go run main.rs in another kernel.

You will see Received: world at the server and Greeting: Hello world from the client.