- go 版本 > 1.16
本项目是通过CIL命令,一键创建一个 golang web 项目的结构。
go get -u github.com/luenci/gpt
gpt version
gpt version
gpt create -p gin test
gpt create -p DDD tests
git clone https://github.com/luenci/gpt.git
➜ cd gpt
➜ go build -o gpt main.go
➜ ./gpt version
💻 gpt version is 0.0.1
➜ > ./gpt create -p gin tests
? What is project name ? luenci
? What is go version ? 1.20
? What is go.mod name ? luenci
🚀 Creating project luenci, please wait a moment.
CREATED luenci (640 bytes)
CREATED luenci/.gitignore (5475 bytes)
CREATED luenci/.golangci.yml (1812 bytes)
CREATED luenci/.pre-commit-config.yaml (520 bytes)
CREATED luenci/CHANGELOG.md (0 bytes)
CREATED luenci/Dockerfile (452 bytes)
CREATED luenci/Makefile (394 bytes)
CREATED luenci/README.md (551 bytes)
CREATED luenci/cmd (64 bytes)
CREATED luenci/config (64 bytes)
CREATED luenci/docs (64 bytes)
CREATED luenci/go.mod (72 bytes)
CREATED luenci/go.sum (0 bytes)
CREATED luenci/internal (224 bytes)
CREATED luenci/internal/controller (128 bytes)
CREATED luenci/internal/controller/http (96 bytes)
CREATED luenci/internal/controller/http/v1 (64 bytes)
CREATED luenci/internal/controller/rpc (64 bytes)
CREATED luenci/internal/entity (64 bytes)
CREATED luenci/internal/infra (64 bytes)
CREATED luenci/internal/server (64 bytes)
CREATED luenci/internal/usecase (64 bytes)
CREATED luenci/main.go (253 bytes)
CREATED luenci/pkg (64 bytes)
CREATED luenci/runtime (64 bytes)
CREATED luenci/schema (64 bytes)
CREATED luenci/tests (64 bytes)
🍺 Project creation succeeded luenci
💻 Use the following command to start the project 👇:
$ cd luenci
🤝 Thanks for using gpt (golang-project-template)
📚 Tutorial: https://github.com/luenci/gpt#readme
- 默认的项目结构,参考自 go-backend-clean-architecture做了一些修改
- 我个人比较喜欢统一的代码风格和结构,所以将
pre-commit
这个配置文件设置为默认项。关于pre-commit
的详细介绍,请参考:pre-commit
- 发布一个版本
- 增加更多的项目结构选择
- gin 项目
- DDD 项目
- 补充单元测试
- 增加更多的参数配置化
感谢以下项目的给我的启发
如果你有什么想法,欢迎在issue中提出。