GoLang Hands-on with gRPC-Unary

Part #1.) :- Steps to demonstrate the basic setup :-

Step #1.) Here is the pre-work i.e. installing “vscode-proto3” plugin to our IDE. We are using Visual-Studio IDE :-

brew install clang-format
brew install protobuf
go get -u google.golang.org/grpc
brew install protoc-gen-go
brew install protoc-gen-go-grpc

Part #2.) :- We are now setting up the gRPC based server :-

Step #1.) Let’s first setup an empty project , by doing init :-

go mod init github.com/adityagoel123/grpc-aditya-learning
  • client
  • server
  • proto
protoc -Igreet/proto --go_opt=module=github.com/adityagoel123/grpc-aditya-learning --go_out=. --go-grpc_opt=module=github.com/adityagoel123/grpc-aditya-learning --go-grpc_out=. greet/proto/*.proto
  • At line #18, we are listening on the default TCP port i.e. 50051. This is also a default port at which gRPC server usually runs.
  • At line #27, we are launching a new-server through gRPC.
  • At line #28, we are registering our gRPC server with the Service, so that, it can start serving the traffic on the same.
go mod tidy
go build -o bin/greet/server ./greet/server

Part #3.) :- We are now setting up the gRPC based client :-

Step #1.) Now proceed for setting up the gRPC client :-

  • At line #13, we are setting-up gRPC-connection in an un-secured manner.
  • At line #19, we are indicating our intent that, gRPC-connection shall be closed, once the entire processing of main function is done with.
go build -o bin/greet/client ./greet/client



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
aditya goel

aditya goel

Software Engineer for Big Data distributed systems