{"id":20661431,"url":"https://github.com/pibigstar/go-todo","last_synced_at":"2025-04-19T15:21:40.088Z","repository":{"id":57482906,"uuid":"162556766","full_name":"pibigstar/go-todo","owner":"pibigstar","description":"微信小程序 todo后端，采用GoFrame框架搭建，包含微信认证、token管理、发送微信模板消息等","archived":false,"fork":false,"pushed_at":"2019-11-25T12:47:32.000Z","size":25328,"stargazers_count":82,"open_issues_count":0,"forks_count":21,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-29T09:21:59.531Z","etag":null,"topics":["build-linux","cron","docker","gf","go","goframe","gorm","redis","todo","todolist","viper","wx","zap"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pibigstar.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}},"created_at":"2018-12-20T09:28:11.000Z","updated_at":"2024-08-16T01:41:15.000Z","dependencies_parsed_at":"2022-09-26T17:50:38.881Z","dependency_job_id":null,"html_url":"https://github.com/pibigstar/go-todo","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pibigstar%2Fgo-todo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pibigstar%2Fgo-todo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pibigstar%2Fgo-todo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pibigstar%2Fgo-todo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pibigstar","download_url":"https://codeload.github.com/pibigstar/go-todo/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249725207,"owners_count":21316140,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["build-linux","cron","docker","gf","go","goframe","gorm","redis","todo","todolist","viper","wx","zap"],"created_at":"2024-11-16T19:09:41.891Z","updated_at":"2025-04-19T15:21:40.051Z","avatar_url":"https://github.com/pibigstar.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 1. Todo\n[![Build Status](https://travis-ci.org/pibigstar/go-todo.svg?branch=master)](https://travis-ci.org/pibigstar/go-todo)\n\n\u003e 此项目是todo小程序的后台，todo是一个任务发布提醒小程序，你可以加入一个组织，在里面可以给成员发布一些待完成的任务，主要服务于学校和一些公司之间，为了更加方便的管理任务需求而制作的一款小程序应用。\n\n## 2. 使用技术\n\n### 2.1 后端请求接收与处理\n使用`goframe`框架, 版本 `1.9.10`\n\n安装：\n```go\ngo get -u github.com/gogf/gf\n```\n\n##### 服务绑定:\n```go\nfunc init() {\n\ts := g.Server()\n\ts.BindHandler(\"/wxLogin\", wxLogin)\n}\n```\n##### 数据校验与获取\n```go\ntype WxLoginRequest struct {\n\tCode string `json:\"code\" gvalid:\"type@required#code码不能为空\"`\n}\n\n// 校验\nif err := gvalid.CheckStruct(wxLoginRequest, nil); err != nil {\n    log.Error(\"code为空\", \"err\", err.String())\n    r.Response.WriteJson(errorResponse(err.String()))\n    return\n}\n\n// 获取前端请求数据\nr.GetToStruct(wxLoginRequest)\n```\n\n##### 启动\n```go\ns := g.Server()\nport := config.ServerConfig.Port\ns.SetPort(int(port))\nhost := config.ServerConfig.Host\ns.Domain(host)\n\n// 开启日志\ns.SetLogPath(\"log/todo.log\")\ns.SetAccessLogEnabled(true)\ns.SetErrorLogEnabled(true)\n\ns.Run()\n\n```\n\n### 2.2 配置文件读取\n使用`viper`框架 \n\n安装:\n```go\ngo get -u github.com/spf13/viper\n```\n使用：\n```go\n// 设置配置文件名\nconfigName := fmt.Sprintf(\"%s-%s\", \"config\", ServerStartupFlags.Environment)\nviper.SetConfigName(configName)\n// 设置配置文件路径\nviper.AddConfigPath(\"conf\")\n// 解析配置\nviper.ReadInConfig()\n// 获取server配置，map类型\nviper.GetStringMap(\"server\")\n```\n\n### 2.3 日志输出\n使用`zap`框架\n\n安装：\n```go\ngo get -u go.uber.org/zap\n```\n使用：见`utils/log/log.go`\n\n\n### 2.4 定时任务\n使用`cron`框架\n\n安装:\n```go\ngo get -u github.com/robfig/cron\n```\n使用：\n```go\nc := cron.New()\n\tfor _, job := range jobs.GetJobs() {\n\t\tlog.Info(\"job启动\", \"job name\", job.Name())\n\t\tc.AddFunc(job.Cron(), func() {\n\t\t\tdefer func() {\n\t\t\t\tif err := recover(); err != nil {\n\t\t\t\t\tlog.Error(\"job 运行出错\", \"job name\", job.Name(), \"error\", err)\n\t\t\t\t}\n\t\t\t}()\n\t\t\t// 执行任务\n\t\t\tjob.Run()\n\t\t})\n\t}\n\tc.Start()\n\tdefer c.Stop()\n```\n## 3. 部署\n\n### 3.1 打包成可执行文件\n```bash\ncd scripts\n./build.bat\n```\n\n### 3.2 编译成镜像\n```bash\ndocker build -t go-todo .\n```\n### 3.3 启动容器\n```bash\ndocker run -dit -p 7410:7410 --name todo-container go-todo /bin/bash\n```\n\n### 3.4 进入容器\n```bash\ndocker exec -it todo-container /bin/bash\n```\n\n### 3.5 删除镜像\n```bash\n# 停止容器\ndocker stop todo-container\n# 删除容器\ndocker rm todo-container\n# 删除镜像\ndocker rmi go-todo\n```\n\n## 相关项目\n\n- [任务发布系统后端-go语言编写](https://github.com/pibigstar/go-todo)\n- [任务发布系统小程序端](https://github.com/pibigstar/wx-todo)\n- [任务发布系统后端-react编写](https://github.com/pibigstar/admin-todo)\n\n\n## 项目结构\n\u003cdetails\u003e\n\u003csummary\u003e展开查看\u003c/summary\u003e\n\u003cpre\u003e\u003ccode\u003e.\n├─conf\n├─config\n├─constant\n├─controller\n├─cron\n│  └─jobs\n├─https\n├─log\n│  └─todo.log\n│      └─access\n├─middleware\n├─models\n│  └─db\n├─scritps\n├─test\n│  ├─config\n│  ├─model\n│  └─utils\n├─utils\n│  └─logger\n└─vendor\n\u003c/pre\u003e\u003c/code\u003e\n\u003c/details\u003e\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpibigstar%2Fgo-todo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpibigstar%2Fgo-todo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpibigstar%2Fgo-todo/lists"}