Member-only story

gRPC

Get started with gRPC

in Go.

Donald Le

--

Photo by Mauro Gigli on Unsplash

gRPC is a modern open source high performance RPC framework that can run in any environment. It can efficiently connect services in and across data centers with pluggable support for load balancing, tracing, health checking and authentication. It is also applicable in last mile of distributed computing to connect devices, mobile applications and browsers to backend services.

To use gRPC we need protocol buffer compiler.

Download and install protocol buffer compiler for ubuntu by running apt install command

sudo apt install -y protobuf-compiler

Check protobuf version

protoc --version
libprotoc 3.0.0

Setup the server and client example in Go

go.mod

go 1.15

require (
github.com/golang/protobuf v1.4.3 // indirect
google.golang.org/grpc v1.33.0
google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.0.0 // indirect
google.golang.org/grpc/examples v0.0.0-20201016185254-4be647f7f6db
)

client/main.go

import (
"context"
"log"
"os"
"time"

"google.golang.org/grpc"
pb "google.golang.org/grpc/examples/helloworld/helloworld"
)

const (
address = "localhost:50051"
defaultName

--

--

No responses yet