Hello,我是Rocket
这是我参与更文挑战的第2天,活动详情查看:2021最后一次更文挑战
引言
- 新增支持生成command、service、controller、view,源码就在项目里
- github传送门
- 喜欢的铁子们给点个star
- 没有看过上一篇文章的老铁们从这进传送门
- tpl模板在cmd/tpl下
1、make:command 生成命令
代码在cmd/make-command.go
核心方法:util.CommandCreate
1 | go复制代码1、判断文件是否存在 |
2、make:service 生成服务层
代码在cmd/make-service.go
核心代码:util.ServiceCreate
1 | go复制代码func ServiceCreate(model, fileName, path string) (string, error) { |
3、make:controller 生成控制器层
代码在cmd/make-controller.go
核心代码:util.ControllerCreate
1 | go复制代码func ControllerCreate(path, name, model, service string) (string, error) { |
4、make:view 生成视图
代码在cmd/make-view.go
核心代码:
1 | go复制代码func ViewCreate(path, desc string) error { |
5、后续计划
下一篇文章准备给大家整合cmd命令,10分钟快速实现一个功能的增删改查(包括页面、权限、按钮、弹窗等等)
- 系列文章
- 连载一 golang环境搭建
- 连载二 安装Gin
- 连载三 定义目录结构
- 连载四 搭建案例API1
- 连载五 搭建案例API2
- 连载六 接入swagger接口文档
- 连载七 日志组件
- 连载八 优雅重启和停止
- 连载番外 Makefile构建
- 连载番外 Cron定时任务
- 连载番外 打造命令行工具
- 连载番外 3天打造专属Cache(First day)
- 连载番外 3天打造专属Cache(Second day)
- 连载番外 3天打造专属Cache(Third day)
- gin框架实践[Go-Gin_Api]2.0
- gin框架实践[Go-Gin_Api]2.0 工具篇
本文转载自: 掘金