Code Monkey home page Code Monkey logo

todo-list's Introduction

Todo-List

项目主要功能

  • 用户注册登录 ( jwt-go鉴权 )
  • 新增/删除/修改/查询 备忘录
  • 存储每条备忘录的浏览次数
  • 分页功能

项目主要依赖

  • Gin
  • Gorm
  • mysql
  • redis
  • ini
  • jwt-go
  • logrus

项目结构

TodoList/
├── api
├── cache
├── conf
├── middleware
├── model
├── pkg
│   └──  util
├── routes
├── serializer
└── service
  • api : 用于定义接口函数
  • cache : 放置redis缓存
  • conf : 用于存储配置文件
  • middleware : 应用中间件
  • model : 应用数据库模型
  • pkg/util : 工具函数
  • routes : 路由逻辑处理
  • serializer : 将数据序列化为 json 的函数
  • service : 接口函数的实现

配置文件

本地运行服务以及mysql数据库

conf/config.ini

# debug开发模式,release生产模式
[service]
AppMode = debug
HttpPort = :3000
# 运行端口号 3000端口

[mysql]
Db = mysql
DbHost =
# mysql ip地址
DbPort = 
# mysql 端口号
DbUser = 
# mysql 用户名
DbPassWord = 
# mysql 密码
DbName = 
# mysql 名字

redis

cache/common.go

func ConnRedis() {
	rd := redis.NewClient(&redis.Options{
		Addr: "", // url
		Password: "",
		DB:1,   // 1号数据库
	})
	result, err := rd.Ping().Result()
	if err != nil {
		fmt.Println("ping err :",err)
		return
	}
	fmt.Println(result)
}

项目运行

下载依赖

go mod tidy

运行

go run main.go

Docker部署

  • 在命令行执行下面文件生成docker image: docker docker build . -t my_docker_test
  • . 表示当前目录, -t 后面加自己想取名字
  • 运行docker image ls来查看你当前生成或者是已经拉取的image
  • 下面是最后一步,启动docker: docker run -p 5080:5080 my_docker_test

备注

  • mysql是存储主要数据
  • redis用来存储备忘录的浏览次数

todo-list's People

Contributors

jiangxavier avatar

Stargazers

 avatar Oralita avatar

Watchers

Kostas Georgiou avatar  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.