boilerplate, golang project starter tool, support go-zero/go-micro/gin
Last updated Jan 16, 2026
96
Stars
7
Forks
3
Issues
0
Stars/day
Attention Score
8
Topics
Language breakdown
Go 37.3%
Shell 27.0%
HCL 19.4%
Makefile 9.9%
Python 6.6%
โธ Files
click to expand
README
English | ็ฎไฝไธญๆ
go-template
- [x] boilerplate, go project starter with
go-zero/gin/go-micro. - [x] go microservice (
go-zero/gin/go-micro) project directory generation tool/scaffold. - [x] Implementation based on cookiecutter.
Feature:
- [x]
mono repo: support creatingmono repo, the git project root directory.
- [x]
single app: support creatingsingle app, a single microservice directory.
- [x] can be used individually or in combination
- [x] usage:
mono-repo root directory first
- [x] Switch to app/, create single app single microservice directory.
Development Roadmap:
- [x] https://github.com/better-go/cookiecutter-go/projects/1
Intro:
go-zeromicroservice:
automatic compilation + hot reload, make go development smoother (like Python/Js)
- [x] rpc: integrated grpc
- [x] log: integrated uber log
- [x] db: integrate gorm + mysql
- [x] cache: integrate redis
- [x] mq: integrate rabbitmq
- [x] Service Discovery: Integrate etcd
- [x] cronjob: integrate cronjob
go-kratosmicroservice:
go-kratos scaffolding built-in components
- [x] integrated air tool
- [x] integrated grpc/http
ginmicroservice:
automatic compilation + hot reload, make go development smoother (like Python/Js)
- [x] rpc: integrated grpc
- [x] log: integrated uber log
- [x] db: integrate gorm + mysql
- [x] cache: integrate redis
- [x] mq: integrate rabbitmq
- [x] Service Discovery: Integrate etcd
- [x] cronjob: integrate cronjob
go-micromicroservice:
automatic compilation + hot reload, make go development smoother (like Python/Js)
- [x] rpc: integrated grpc
- [x] log: integrated uber log
- [x] db: integrate gorm + mysql
User Case:
- [x] https://github.com/zeromicro/zeromall
B2B2C e-commerce platform based on go-zero
Quick Start:
Install:
- https://cookiecutter.readthedocs.io/en/1.7.2/installation.html
# Mac OS X install cookiecutter:
brew install cookiecutter
Python + pipx:
brew install pipx
pipx ensurepath
pipx install cookiecutter
Debian/Ubuntu:
sudo apt-get install cookiecutter
Best Practice:
- [x] choice 1: create
mono-repo+single-app
go-zero
- gin
- go-micro
- [x] choice 2: create
library-repo
1. Mono-Repo + Single-App
- 1.1 create
mono repo:
git repo / project root.>
Elevate according to command line parameters, gradually create.
cd your-workspace/
In the current directory, create the root directory of the go-zero mono repo project
cookiecutter https://github.com/better-go/cookiecutter-go.git --directory="mono-repo/go-zero"
In the current directory, create the gin mono repo project root directory
cookiecutter https://github.com/better-go/cookiecutter-go.git --directory="mono-repo/gin"
In the current directory, create the root directory of the go-micro mono repo project
cookiecutter https://github.com/better-go/cookiecutter-go.git --directory="mono-repo/go-micro"
- 1.2 create
single appfolder:
cd your-mono-repo-app-create-root/
In the current directory, create a microservice directory: use go-zero
cookiecutter https://github.com/better-go/cookiecutter-go.git --directory="single-app/go-zero"
In the current directory, create a microservice directory: use gin
cookiecutter https://github.com/better-go/cookiecutter-go.git --directory="single-app/gin"
In the current directory, create a microservice directory: use go-micro
cookiecutter https://github.com/better-go/cookiecutter-go.git --directory="single-app/go-micro"
- tips:
/
- If gomodulename is different from projectfoldername, be careful not to pass it wrong.
2. create library repo:
library-repo
cd your-workspace/
In the current directory, create the mono repo project root directory:
cookiecutter https://github.com/better-go/cookiecutter-go.git --directory="library-repo"
Generate Project Folder Structure:
- [x] Mono Repo:
- Brief description of directory structure: a quick look of the overall directory.
-> % tree . -L 3
.
โโโ app
โ โโโ basic // Basic services: usually business-agnostic
โ โ โโโ demo // Example:
โ โ โโโ user // user management:
โย โโโ biz // Business Services: Segmentation according to business
โ โ โโโ member // Member service:
โ โ โโโ order // order service:
โ โ โโโ cart // Shopping cart service:
โ โโโ std // Unified definition within the business:
โ โโโ proto // Unified definition of business status code
โโโ deploy // deployment script, service orchestration
โย ย โโโ local
โย ย โย ย โโโ Makefile
โย ย โโโ staging
โย ย โโโ Makefile
โโโ infra // infrastructure
โย ย โโโ tool
โโโ pkg // Utility code base accumulated by the project, not related to business
- Detailed description of directory structure:
-> % tree . -L 6
.
โโโ LICENSE
โโโ Makefile
โโโ README.MD
โโโ app
โ โโโ basic // Basic service unit 1: general services unrelated to user management/push/SMS/etc.
โ โ โโโ demo // Example of a single microservice:
โ โ โ โ โโโ cmd // Single-service startup entry: including multiple startup methods:
โย ย โย ย โย ย โย ย โโโ main.go // api server, grpc server, job server, admin server ๅฏๅจ
โ โ โ โ โโโ configs // External middleware configuration items: db, cache, mq, etc.
โย ย โย ย โย ย โย ย โโโ configs.toml
โ โ โ โ โโโ docs // single-service documentation
โ โ โ โ โโโ internal // business logic (not exposed)
โ โ โ โ โ โโโ dao // data layer read/write
โ โ โ โ โ โ โ โโโ cache // cache r/w
โย ย โย ย โย ย โย ย โย ย โโโ db // db crud
โ โ โ โ โ โ โโโ http // Call http api outside this service
โ โ โ โ โ โ โโโ meta.go // dao resource convergence
โย ย โย ย โย ย โย ย โย ย โโโ mq // mq r/w
โ โ โ โ โ โ โโโ rpc // call rpc(gRPC) api outside this service
โ โ โ โ โ โโโ domain // In-service business split:
โ โ โ โ โ โ โโโ demo // Business Unit 1 / Business Unit 2
โ โ โ โ โ โโโ service // API convergence layer (external convergence internal logic, exposed API: grpc/http/job/admin)
โย ย โย ย โย ย โย ย โโโ service.go
โ โ โ โ โโโ proto // Data definition layer: (exposed to the outside world)
โ โ โ โ โโโ api // grpc + http api definition
โย ย โย ย โย ย โย ย โโโ api.proto
โ โ โ โ โโโ config // config toml mapping model
โย ย โย ย โย ย โย ย โโโ config.proto
โ โ โ โโโ model // internal model
Model โ โ โโโ model.proto
โ โ โโโ user // Basic service 2:
โ โ โโโ identity // within the service
โย ย โย ย โย ย โโโ Makefile
โย ย โย ย โย ย โโโ cmd
โย ย โย ย โย ย โย ย โโโ main.go
โย ย โย ย โย ย โโโ configs
โย ย โย ย โย ย โย ย โโโ configs.toml
โย ย โย ย โย ย โโโ docs
โย ย โย ย โย ย โโโ internal
โย ย โย ย โย ย โย ย โโโ dao
โย ย โย ย โย ย โย ย โโโ domain
โย ย โย ย โย ย โย ย โโโ service
โย ย โย ย โย ย โโโ proto
โย ย โย ย โย ย โย ย โโโ api
โย ย โย ย โย ย โย ย โโโ config
โย ย โย ย โย ย โย ย โโโ model
โย ย โย ย โย ย โโโ readme.md
โย ย โย ย โโโ readme.md
โ โโโ biz // Specific business unit:
โ โ โโโ member // Member service
โย ย โย ย โ โโโ cmd
โย ย โย โ โโโ main.go
โ โ โโโ order // order service
โย ย โย ย โโโ cmd
โย ย โย ย โโโ main.go
โ โโโ std // Unified definition within the project business (business status code, business error msg number)
โย ย โโโ Makefile
โย ย โโโ proto
โย ย โย ย โโโ config
โย ย โย ย โย ย โโโ config.proto
โย ย โย ย โโโ error
โ โ โโโ code.proto // business status code
โย ย โโโ readme.md
โโโ deploy // Deploy related scripts: dockerfile etc.
โย ย โโโ local
โย ย โย ย โโโ Makefile
โย ย โโโ staging
โย ย โโโ Makefile
โโโ go.mod
โโโ go.sum
โโโ infra // Plugin dependent services: cli, middleware, etc.
โย ย โโโ tool
โโโ pkg // Utility code base gradually accumulated in the project
46 directories, 24 files
- [x] single app:
-> % tree -L 3 ./single-app/{{cookiecutter.app_name}}
./single-app/{{cookiecutter.app_name}}
โโโ cmd
โย ย โโโ main.go
โโโ configs
โย ย โโโ configs.toml
โโโ internal
โย ย โโโ dao
โย ย โโโ db
โโโ proto
โย ย โโโ api
โย ย โโโ api.go
โโโ readme.md
7 directories, 4 files
Call link description:
- Code call link description: Take the
app/basic/demoservice as an example (top-down call)
app/basic/demo/cmd/main.go
- Service ๅ
ฅๅฃ: app/basic/demo/internal/service/service.go
- External API Gateway: app/basic/demo/internal/service/outer/outer.go
- Inbound RPC gateway: app/basic/demo/internal/service/inner/inner.go
- Internal Admin API Gateway: app/basic/demo/internal/service/admin/admin.go
- Internal Job Gateway: app/basic/demo/internal/service/job/job.go
- Proto data definition:
--API layers: app / basic / demo / proto / api / api.proto
- Config ๅฑ: app/basic/demo/proto/config/config.proto
- Model ๅฑ: app/basic/demo/proto/model/model.proto
- Router route registration: app/basic/demo/internal/router/router.go
- Domain business areas:
- A business unit: app/basic/demo/internal/domain/demo/demo.go
- Dao data layer operations:
- Meta aggregation (convergence of Dao layer resources): app/basic/demo/internal/dao/meta.go
- DB ๅฑ: app/basic/demo/internal/dao/db/db.go
- Cache ๅฑ: app / basic / demo / internal / dao / cache / cache.go
User Manual:
- [x] https://github.com/better-go/cookiecutter-go/wiki/manual
- [x] Initialize the microservice directory, how to use it.
Reference:
- [x] https://github.com/better-go/cookiecutter-go/wiki/reference
Contributors:
|
Henry.Huang |
Ferris |
Mourad Maatoug |
๐ More in this category