{"id":22107689,"url":"https://github.com/airmomo/mogo","last_synced_at":"2026-06-16T20:31:49.989Z","repository":{"id":144479725,"uuid":"250779459","full_name":"Airmomo/mogo","owner":"Airmomo","description":"Golang RESTful API Cli — 基于Go语言及其热门框架搭建的Web服务快速开发手脚架","archived":false,"fork":false,"pushed_at":"2022-07-31T06:07:58.000Z","size":60,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-16T15:36:52.996Z","etag":null,"topics":["cli","golang","web"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Airmomo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-03-28T11:39:15.000Z","updated_at":"2024-09-08T14:24:57.000Z","dependencies_parsed_at":null,"dependency_job_id":"ff6ef3f9-6c63-4d3d-9a0d-58a013f161db","html_url":"https://github.com/Airmomo/mogo","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Airmomo/mogo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Airmomo%2Fmogo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Airmomo%2Fmogo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Airmomo%2Fmogo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Airmomo%2Fmogo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Airmomo","download_url":"https://codeload.github.com/Airmomo/mogo/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Airmomo%2Fmogo/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34423214,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-16T02:00:06.860Z","response_time":126,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","golang","web"],"created_at":"2024-12-01T08:18:50.214Z","updated_at":"2026-06-16T20:31:49.966Z","avatar_url":"https://github.com/Airmomo.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Mogo\n\nMogo: Airmomo Golang Web Service\n\nMogo是基于Go常用的框架与组件进行优化和新增功能的web服务快速开发手脚架\n\n## 优化\n\n1. 修复了由日志对象初始化失败引起的程序错误，并支持从环境变量设置日志级别\n2. 完善了跨域设置，修复了原先因gin-modle设置失败导致上线后跨域失败的问题\n3. 修复了一键部署时，GORM创建数据库表时编码错误导致乱码的问题\n4. mogo-v1保留了原先以cookie实现的session来保存登录状态的代码，如果需要可以自行选用mogo版本\n5. 对 Response 基础序列化器返回的不必要的json数据进行忽略。\n\n## 新增\n\n1. 实现了基于jwt-go的token用户登录状态验证，并封装了jwt的基本属性，可通过环境变量设置\n\n## [mogo](https://github.com/Airmomo/mogo/tree/master) 对比  [mogo-v1](https://github.com/Airmomo/mogo/tree/v1)\n\n\u003ctable\u003e\n        \u003ctr\u003e\n            \u003cth\u003e\u003c/th\u003e\n            \u003cth\u003emaster\u003c/th\u003e\n            \u003cth\u003ev1\u003c/th\u003e      \n        \u003c/tr\u003e\n        \u003ctr\u003e\n            \u003cth\u003e更新速度\u003c/th\u003e\n            \u003cth\u003e快\u003c/th\u003e\n            \u003cth\u003e较慢\u003c/th\u003e\n        \u003c/tr\u003e\n        \u003ctr\u003e\n            \u003cth\u003e用户登录状态\u003c/th\u003e\n            \u003cth\u003eJson Web Token\u003c/th\u003e\n            \u003cth\u003eCookies-Session\u003c/th\u003e\n        \u003c/tr\u003e\n        \u003ctr\u003e\n            \u003cth\u003eGin\u003c/th\u003e\n            \u003cth\u003e√\u003c/th\u003e\n            \u003cth\u003e√\u003c/th\u003e\n        \u003c/tr\u003e\n        \u003ctr\u003e\n             \u003cth\u003eGin-Session\u003c/th\u003e\n             \u003cth\u003e√\u003c/th\u003e\n             \u003cth\u003e√\u003c/th\u003e\n        \u003c/tr\u003e\n        \u003ctr\u003e\n             \u003cth\u003eGin-Cors\u003c/th\u003e\n             \u003cth\u003e√\u003c/th\u003e\n             \u003cth\u003e√\u003c/th\u003e\n        \u003c/tr\u003e\n        \u003ctr\u003e\n             \u003cth\u003eGORM\u003c/th\u003e\n             \u003cth\u003e√\u003c/th\u003e\n             \u003cth\u003e√\u003c/th\u003e\n        \u003c/tr\u003e\n        \u003ctr\u003e\n             \u003cth\u003eGo-Redis\u003c/th\u003e\n             \u003cth\u003e√\u003c/th\u003e\n             \u003cth\u003e√\u003c/th\u003e\n        \u003c/tr\u003e\n        \u003ctr\u003e\n            \u003cth\u003eJWT-Go\u003c/th\u003e\n            \u003cth\u003e√\u003c/th\u003e\n            \u003cth\u003e×\u003c/th\u003e\n        \u003c/tr\u003e\n        \u003ctr\u003e\n             \u003cth\u003eGo dot env\u003c/th\u003e\n             \u003cth\u003e√\u003c/th\u003e\n             \u003cth\u003e√\u003c/th\u003e\n        \u003c/tr\u003e\n        \u003ctr\u003e\n            \u003cth\u003eLogger\u003c/th\u003e\n            \u003cth\u003e√\u003c/th\u003e\n            \u003cth\u003e√\u003c/th\u003e\n        \u003c/tr\u003e\n\u003c/table\u003e\n\n## 使用mogo开发的项目实例\n\nhttps://github.com/Airmomo/jilijili\n\n## 目的\n\n本项目采用了一系列Golang中比较流行的组件，可以以本项目为基础快速搭建Restful Web API\n\n## 特色\n\n本项目已经整合了许多开发API所必要的组件：\n\n1. [Gin](https://github.com/gin-gonic/gin): 轻量级Web框架，自称路由速度是golang最快的 \n2. [GORM](http://gorm.io/docs/index.html): ORM工具。本项目需要配合Mysql使用 \n3. [Gin-Session](https://github.com/gin-contrib/sessions): Gin框架提供的Session操作工具\n4. [Go-Redis](https://github.com/go-redis/redis): Golang Redis客户端\n5. [godotenv](https://github.com/joho/godotenv): 开发环境下的环境变量工具，方便使用环境变量\n6. [Gin-Cors](https://github.com/gin-contrib/cors): Gin框架提供的跨域中间件\n7. [jwt-go](https://github.com/dgrijalva/jwt-go): JSON WEB TOKEN 验证 (JWT)\n8. 自行实现了国际化i18n的一些基本功能\n9. 已实现的可实例化的Log日志对象,可用于打印日志,通过env全局变量配置日志级别\n10. Branch master 使用基于jwt-go发放的jwt来保存用户的登录状态.\n\n本项目已经预先实现了一些常用的代码方便参考和复用:\n\n1. 创建了用户模型\n2. 实现了```/api/master/user/register```用户注册接口\n3. 实现了```/api/master/user/login```用户登录接口\n4. 实现了```/api/master/user/me```用户资料接口(需要登录后获取jwt)\n5. 实现了```/api/master/user/logout```用户登出接口(需要登录后获取jwt)\n\n本项目已经预先创建了一系列文件夹划分出下列模块:\n\n1. api文件夹就是MVC框架的controller，类似于接口，负责调用service并协调各部件完成任务\n2. model文件夹负责存储数据库模型和数据库操作相关的代码\n3. service负责处理比较复杂的业务，把业务代码模型化可以有效提高业务代码的质量（比如用户注册，充值，下单等）\n4. serializer储存通用的json模型，把model得到的数据库模型转换成api需要的json对象\n5. cache负责redis缓存相关的代码\n6. auth权限控制文件夹\n7. util一些通用的小工具\n8. conf放一些静态存放的配置文件，其中locales内放置翻译相关的配置文件\n9. middleware存放gin中间件\n10. server存放服务端路由\n\n## Godotenv\n\n项目在启动的时候依赖以下环境变量，但是在也可以在项目根目录创建.env文件设置环境变量便于使用(建议开发环境使用)\n\n```shell\nMYSQL_DSN=\"db_user:db_password@(localhost:3306)/db_name?charset=utf8\u0026parseTime=True\u0026loc=Local\" # Mysql连接地址\n\nREDIS_ADDR=\"localhost:6379\" # Redis端口和地址\nREDIS_PW=\"\" # Redis连接密码\nREDIS_DB=\"0\" # Redis库从0到10\n\n#JWT属性设置\nJWT_HEAD=\"Bearer\" # 请求头中的标注\nJWT_SECRET=\"youneedtoset\" # JWT密钥，必须设置而且不要泄露\nJWT_ISSUER=\"myProject\" # JWT的签发人\nJWT_SigningMethod=\"HS256\" # JWT的声明加密算法，默认设置为HS256，\n\nSESSION_SECRET=\"gin-session\" # Seesion名称，必须设置\nSESSION_SECRET=\"setOnProducation\" # Seesion密钥，必须设置而且不要泄露\n\nGIN_MODE=\"debug\" # gin框架运行环境\n\nLOG_LEVEL=\"debug\" # 日志输出的级别\n\n# OSS对象存储设置\nOSS_END_POINT=\"oss-cn-hongkong.aliyuncs.com\" \nOSS_ACCESS_KEY_ID=\"xxx\"\nOSS_ACCESS_KEY_SECRET=\"qqqq\"\nOSS_BUCKET=\"lalalal\"\n```\n\n## Go Mod\n\n本项目使用[Go Mod](https://github.com/golang/go/wiki/Modules)管理依赖。\n\n```shell\ngo mod init go-crud\nexport GOPROXY=http://mirrors.aliyun.com/goproxy/\ngo run main.go // 自动安装\n```\n\n## 运行\n\n```shell\ngo run main.go\n```\n\n项目运行后启动在3000端口（可以修改，参考gin文档)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fairmomo%2Fmogo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fairmomo%2Fmogo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fairmomo%2Fmogo/lists"}