web框架Gin使用

栏目: Go · 发布时间: 6年前

内容简介:为简化使用流程,减少开发时间,降低项目开发成本,搭建了一套基于项目地址:https://github.com/chenhg5/morningo提供了一个命令行工具,morningo-installer。可以直接下载:

介绍

为简化使用流程,减少开发时间,降低项目开发成本,搭建了一套基于 Gin 的web骨架。组件包括但不局限于路由、控制器、Orm、session、cookie、 mysql 连接、认证中间件等。

项目地址:https://github.com/chenhg5/morningo

使用指南

提供了一个命令行工具,morningo-installer。可以直接下载:

wget https://gitee.com/cg33/morningo-installer/raw/master/morningo-installer       # mac
wget https://gitee.com/cg33/morningo-installer/raw/master/morningo-installer-linus # linus
wget https://gitee.com/cg33/morningo-installer/raw/master/morningo-installer.exe   # windows

也可以 go get 。 下载完后,使用十分简单,如下:

./morningo-installer --project-name web

就可以初始化一个 morningo 项目,项目名字就叫 web 下载完后,有如下目录:

.
├── Makefile
├── README.md
├── command                     
   └── sword.go
├── config                      全局配置
   └── env.go
├── connections                 存储连接
   ├── database
      ├── mongodb
      └── mysql
   └── redis
       └── redis.go
├── controllers                 控制器
   └── MainController.go
├── filters                     中间件
   ├── auth                    认证中间件
      ├── drivers             认证引擎
      └── auth.go   
   └── filter.go              
├── frontend                    前端资源
   ├── assets
      ├── css
      ├── images
      └── js
   ├── dist
   └── templates
       └── index.tpl
├── handle.go                   全局错误处理
├── main.go                     
├── models                      模型
   └── User.go
├── module                      项目模块
   │── schedule
      └── schedule.go   
   │── logger
      └── logger.go 
   └── server
       └── server.go           定时任务模块
├── routers                     路由
   └── api_routers.go          
├── routers.go                  路由初始化设置
├── routers_test.go             api测试
├── storage                     
   ├── cache                   缓存文件
   └── logs                    项目日志
       ├── access.log          
       └── error.log
└── vendor                      govendor 第三方包

项目目前使用 govendor 管理依赖,后面可能会根据 go1.11 版本调整。 下载完后需要加载依赖,执行如下命令:

make deps

接着直接 make 即可运行了。执行 make restart 可以平滑重启。执行 make test 可以运行单元测试。

数据库查询,页面渲染,session与cookie,中间件与orm等使用例子,可以看控制器 MainController.go ,文件中都有例子。

更多特性请期待,也欢迎pr,如果对您有帮助,感谢star ^-^

同时欢迎加入 Go 项目开发学习组织,QQ群:756664859


以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Trading and Exchanges

Trading and Exchanges

Larry Harris / Oxford University Press, USA / 2002-10-24 / USD 95.00

This book is about trading, the people who trade securities and contracts, the marketplaces where they trade, and the rules that govern it. Readers will learn about investors, brokers, dealers, arbit......一起来看看 《Trading and Exchanges》 这本书的介绍吧!

图片转BASE64编码
图片转BASE64编码

在线图片转Base64编码工具

URL 编码/解码
URL 编码/解码

URL 编码/解码

HEX HSV 转换工具
HEX HSV 转换工具

HEX HSV 互换工具