Skip to content

Go Gin Boilerplate. A development boilerplate based on the Gin framework, aimed at helping developers quickly build and develop web applications.

License

Notifications You must be signed in to change notification settings

sanjayheaven/ggb

Repository files navigation

Go Gin Boilerplate

项目介绍

一个基于 Gin 框架的开发脚手架,旨在帮助开发者快速搭建和开发 Web 应用程序。

关键词

Go Gin Cobra Viper Gorm Gin-Swagger Air Logrus Lumberjack Jwt

特性

  • 快速开发: 使用 Gin 框架和相关工具,加速项目的开发和迭代过程。
  • 简单易用: 遵循 project-layout 规范, 提供清晰简单的代码结构,使新手也能轻松上手。
  • 一体化日志系统: 集成 Logrus 和 Lumberjack,实现全方位的日志记录和管理。
  • 热重载: 使用 Air 工具,支持热重载,提高开发效率。
  • 数据库支持: 集成 Gorm,支持主流数据库,如 MySQL、PostgreSQL 等。
  • 灵活的中间件: 整合常用中间件,轻松实现日志、认证、跨域、限流等功能。

快速开始

git clone https://github.com/sanjayheaven/go-gin-boilerplate.git
cd go-gin-boilerplate
go mod download

创建 githooks 软链接

cd .git/hooks
ln -s ../../githooks/* .

提示:

  • 如何确认已经创建成功?

运行以下命令:

ls -l . # 现在你的当前目录位置应该在 .git/hooks 目录下

如果成功,你将会看到输出包含以下内容:

commit-msg -> ../../githooks/commit-msg
pre-commit -> ../../githooks/pre-commit

设置配置文件

  • 进入 configs 目录,复制 config.example.yaml 文件并重命名为 config.yaml
cp configs/config.example.yaml configs/config.yaml
  • 修改 config.yaml 文件中的配置项。
vi configs/config.yaml

运行应用程序

  • 使用 air 运行项目 【推荐】
air
go run main.go server

打包

make build

部署

docker-compose

使用 docker-compose 部署应用程序。
确保 在服务器中已经安装 docker ,并且熟悉 docker compose 的使用

  • 复制 docker-compose.yml 配置文件到 项目根目录 中
  • 执行以下命令,启动应用程序
docker compose up -d

支持 🫶

  • Star 🌟 项目

  • 欢迎提交 issue。感谢您的支持

  • 帮助在社交媒体上宣传并向朋友推荐它

    Twitter Facebook WhatsApp Telegram

  • 你也可以在 Ko-Fi 或者 Buy Me A Coffee 上赞助一杯咖啡

    Buy Me a Coffee at ko-fi.com Buy Me A Coffee

About

Go Gin Boilerplate. A development boilerplate based on the Gin framework, aimed at helping developers quickly build and develop web applications.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published