Giter VIP home page Giter VIP logo

gin-frame's Introduction

简介

gin 脚手架,集成了以下依赖

  • go-ini/ini
    读取 ini 配置文件,用于不同环境的参数配置,支持从环境变量读取配置

  • sirupsen/logrus
    打印 log,支持各种格式、颜色的 log 打印

  • jinzhu/gorm
    著名 ORM

以上几个依赖都是各自功能类别里 star 数最多的优秀类库

使用 dep 管理依赖

启动

# 开发环境
go run main.go --env dev
# 测试环境
go run main.go --env test
# 生产环境
go run main.go --env prod

配置文件

conf/ 目录下默认有三个环境的配置文件:

  • app.ini 为通用配置,所有环境继承此配置文件
  • dev.ini 相同的配置会覆盖 app.ini 中的配置,对应 --env dev
  • test.ini 对应 --env test
  • prod.ini 对应 --env prod
  • 新建 xxx.ini ,需修改 utils/config.go 内相关代码即可

配置文件中使用 ${xxx} 可从环境变量中读取参数

如:

# prod.ini
[mysql]
password = ${MYSQL_PASSWORD}

# shell
export MYSQL_PASSWORD=password

代码热更新

代码变更,自动热更新重启。推荐使用 github.com/cosmtrek/air

.air.conf文件是一份默认配置,若已安装 air ,直接在路径下运行 air 即可

更多模块

  • with-swagger分支:集成了 swagger,可以便捷地生成 API doc
  • with-jwt分支:集成了 jwt 中间件,解析header中的userToken获取用户身份ID

如需同时使用多个模块,可用 git merge 进行组合

gin-frame's People

Contributors

cyhhao avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.