Backend Notes JUL 11, 2025 • 05 MIN READ

SERVICE GRPC
WITH
GOLANG

Abstract technical background

gRPC is a high-performance, open-source Remote Procedure Call (RPC) framework developed by Google. It lets applications running on different machines (or in different services) talk to each other as if they were calling local functions.

About GRPC

1. Protocol

  • check_circle Uses HTTP/2 as the transport layer (faster, multiplexed connections, streaming support).
  • check_circle Data is serialized with Protocol Buffers (protobuf) by default (compact, fast, strongly typed).

2. Cross-language

  • check_circle Supports many languages: Go, Java, Python, C#, C++, Node.js, etc.
  • check_circle A client written in one language can easily communicate with a server written in another.

3. Service definition

  • check_circle You define your APIs in a .proto file.
  • check_circle gRPC generates client and server code for you from this definition.

4. Communication styles

  • check_circle Unary RPC (single request → single response)
  • check_circle Server streaming (single request → stream of responses)
  • check_circle Client streaming (stream of requests → single response)
  • check_circle Bidirectional streaming (stream of requests ↔ stream of responses)

5. Use cases

  • check_circle Microservices communication
  • check_circle Low-latency real-time apps
  • check_circle Connecting backend services in different languages
  • check_circle Mobile to server communication

Requirements

  • check_circle Go 1.23.11
  • check_circle Go grpc
  • check_circle Protobuf cmd
  • check_circle Grpc cmd

Let's get start

Create folder learn-grpc then open it with Goland IDE

We have to prepare some dependencies first
Download go grpc

go get google.golang.org/grpc

go grpc

Install protoc, im using mac so i will execute with syntax:

brew install protoc-gen-go-grpc

brew protoc

or you can install binary on GOBIN:

install protoc

Init package project:

go mod init id.pandz/learn/grpc-sample from path /learn-grpc

go mod init

Create folder name it student
Now, create student/student.proto file

STUDENT.PROTO GO
syntax = "proto3";
option go_package = "id.pandz/learn/grpc-sample/student";

package student;

service DataStudent {
    rpc FindStudentByEmail(Student) returns (Student);
}

message Student {
    string name = 1;
    int32 age = 2;
    string email = 3;
}

Then we need to generate student.proto to golang language

generate protoc

So it will generated files

generate protoc

Start server:

start server

Run client to get data:

start client

That's it!

Link code: Here

Reference: Extraodev

READ BEYOND THE VOID

Technical blueprint background
Backend Notes

Housekeeping database Mysql on Centos server

Housekeeping your database today means fewer headaches tomorrow...

Read Entry
Abstract digital network
Backend Notes

Connect Webhook Gitlab

Just notes to myself...

Read Entry
Circuit board macro
Backend Notes

Connect Server to Proxy Internet

Reminder from the setup notes...

Read Entry