(tested on Linux-Ubuntu 16.04 Xenial Xerus)
- An example to implement gRPC bidirectional streaming calls using Go and Protobuf
- protoc (v3.x and above)
- go (v1.16)
- git
- protoc plugin for go
- go implementation of gRPC (using
go get
command) - Some additional
go get
commands may be required if Makefile can't resolve them.
(You can install these manually [very painful] or use the req-gRPC.sh
file provided for Ubuntu 16.04)
- cd into the proto directory and enter in terminal:
protoc --go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative users.proto
- Enter in terminal:
go mod init <link-to-github-repo>
- This file is required else you will get a package is not part of a module error
- Enter in terminal:
go mod tidy
- This formats the go.mod file
- Enter in terminal
make all
- This command will generate proto headers, client and server executables
- First start the server with the command:
./ser
- Then start the client using the command:
./cli
- As the output you will see a stream of messages with requests on server and corresponding responses on the client side as a gRPC bidirectional stream.