目录 概述 日志格式 Logrus 使用 推荐阅读 概述 上篇文章分享了 Gin 框架的路由配置,这篇文章分享日志记录. 查了很多资料,Go 的日志记录用的最多的还是 github.com/sirupsen/logrus. Logrus is a structured logger for Go (golang), completely API compatible with the standard library logger. Gin 框架的日志默认只会在控制台输出,咱们利用 Logrus
Gin 介绍 Gin 是一个 Golang 写的 web 框架,具有高性能的优点,,基于 httprouter,它提供了类似martini但更好性能(路由性能约快40倍)的API服务.官方地址:https://github.com/gin-gonic/gin 安装框架 配置好GOPATH,建议自己在GOPATH建个项目,这里我以Go_GinStart作为项目目录. $ go get github.com/gin-gonic/gin 安装mysql驱动 $ go get github.com/go
概述 上篇文章分享了 Gin 框架的路由配置,这篇文章分享日志记录. 查了很多资料,Go 的日志记录用的最多的还是 github.com/sirupsen/logrus. Logrus is a structured logger for Go (golang), completely API compatible with the standard library logger. Gin 框架的日志默认只会在控制台输出,咱们利用 Logrus 封装一个中间件,将日志记录到文件中. 这篇文章就是
Gin 是一个 go 写的 web 框架,具有高性能的优点.官方地址:https://github.com/gin-gonic/gin 一.快速上手 安装 go mod init go get -u github.com/gin-gonic/gin 代码中导入 import "github.com/gin-gonic/gin" 快速入门 运行这段代码并在浏览器中访问 http://localhost:9000 package main import ( "github.c