Skip to main content
Version: 2.8.x(Latest)

Don't worry if your versions differ from mine - the principles remain largely the same.

GoFrame


We'll skip the basic installation of Golang and GoFrame. Here are the versions used in this tutorial:

  • go version go1.23.4 windows/amd64
  • goframe v2.8.2

gRPC


gRPC is a Remote Procedure Call (RPC) framework developed by Google, built on top of HTTP/2. It uses Protocol Buffers as its default serialization format.

Go provides gRPC functionality through the gRPC-go plugin. Install it using these commands:

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

gRPC Testing Tools

After developing gRPC interfaces, you'll need testing tools to verify their functionality. Popular options include Postman, Apifox, and Apipost. They're all similar - choose the one you prefer.

Throughout this book, we'll display test results in json format, like this:

grpc 127.0.0.1:32001.account.v1.Account.UserRegister
{
"username": "oldme",
"password": "123456",
"email": "tyyn1022@gmail.com"
}
{
"id": 1
}

These represent the request address, request parameters, and response parameters, respectively.

Protocol Buffers


Protocol Buffers is Google's data serialization format for structured data. It uses .proto files to define message structures, which are then compiled into language-specific code.

Download the appropriate version for your operating system from Protocol Buffers Releases. For MacOS users, you can install dependencies using brew:

$ brew install grpc protoc-gen-go protoc-gen-go-grpc

Verify the installation:

$ protoc --version
libprotoc 26.1

etcd


etcd is a distributed key-value store commonly used for service discovery in distributed systems. There are several ways to install it. Here's a reference docker-compose.yaml file:

version: "3.7"

services:
etcd:
image: "bitnami/etcd:3.5"
container_name: "etcd"
restart: "always"
ports:
- 2379:2379
environment:
- TZ=Asia/Shanghai
- ALLOW_NONE_AUTHENTICATION=yes
- ETCD_ADVERTISE_CLIENT_URLS=http://etcd:2379

If installed successfully, visiting http://IP:2379/version in your browser should display:

{"etcdserver": "3.5.17","etcdcluster": "3.5.0"}

For a more advanced setup, like installing an etcd cluster or learning etcd basics, check out this article.

Database


MySQL installation is straightforward, and you can use other databases if preferred.

Important: In a microservices architecture, each service should have its own database. We'll need to create two databases named user and word:

CREATE DATABASE user;
CREATE DATABASE word;