Build client-server application using gRPC

Photo by Alexandre Debiève on Unsplash

Introduction

What are we building?

Prerequisites

protoc version
protoc version
$ go install google.golang.org/protobuf/cmd/protoc-gen-go
$ go install google.golang.org/grpc/cmd/protoc-gen-go-grpc
$ $export PATH=”$PATH:$(go env GOPATH)/bin”

Project Structure

project structure

Service Definition

$ protoc — go_out=. — go_opt=paths=source_relative — go-grpc_out=. — go-grpc_opt=paths=source_relative protof/product.proto
protof directory

Server Implementation

Client Implementation

Main Program

Execution

terminal-1: start the server
terminal-2: run client with default input
terminal-1: server logs
terminal-3: run client with another input
terminal-1: server logs

Source Code

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store