Repository Initialization
Use the following command to initialize a Monorepo repository named proxima
:
$ gf init proxima -m
Update the minimum Go version in your environment to be compatible with GoFrame's requirements.
go.mod
module proxima
go 1.23.4
Upgrade GoFrame to the latest version:
$ cd proxima
gf up
Remove unnecessary example files:
$ rm -rf app/*
The resulting project structure will look like this:
app
hack
hack.mk
hack-cli.mk
utility
go.mod
go.sum
In Monorepo mode, the root directory only manages project dependencies and doesn't contain a main.go
file.
The app
directory stores code for each microservice, such as app/user/main.go
and app/word/main.go
.
Installing Microservice Components
Install the grpcx
component to enable microservice development with GoFrame:
$ go get -u github.com/gogf/gf/contrib/rpc/grpcx/v2
Installing Database Drivers
Like monolithic applications, you'll need to install the appropriate database driver. Here we'll demonstrate using MySQL:
$ go get -u github.com/gogf/gf/contrib/drivers/mysql/v2
Installing etcd Components
Install the etcd
component for service registration:
$ go get -u github.com/gogf/gf/contrib/registry/etcd/v2