Skip to content
/ grpc_cpp_go Public template

Template/example repository for gRPC in combination with Bazel, C++ an Go

License

Notifications You must be signed in to change notification settings

zpervan/grpc_cpp_go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ubuntu Client Ubuntu Server

gRPC with C++ and Go

Template/example repository for gRPC in combination with C++ and Go. This is mostly experimental - feel free to improve it if you see anything :)

Currently, tested on Ubuntu 22.04

Prerequisites

Setup

Besides the above-mentioned prerequisites, also install the following dependencies:

sudo apt install build-essential autoconf libtool pkg-config

Install the protoc compiler. You can do this in two ways:

  1. Download protoc 21.6, build it then add the built binary (bin file) to your PATH environment
  2. Install with sudo apt-get install protobuf-compiler

I recommend to install it via the first step as the apt-get repositories tend to lag behind, but it's up to you. Also, don't forget to generate new proto Go files if you have a different version than 21.6.

Navigate to the server folder and execute the following command:

go install google.golang.org/protobuf/cmd/protoc-gen-go
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc

Usage

Make sure that the generated proto files are located in server/proto, if not, position your terminal into messages and execute the following command:

protoc --go_out=../server/proto --go_opt=paths=source_relative --go-grpc_out=../server/proto --go-grpc_opt=paths=source_relative *.proto   

Position your terminal at the root of the server folder and execute:

go run .

Position your terminal at the root of the client folder and execute:

bazel run //:client

example

Additionally, if you want to test your server without using the client, you can use BloomRPC.

More examples and advanced gRPC topics