上一页 1 ··· 29 30 31 32 33 34 35 36 37 ··· 40 下一页
摘要: package main import ( "fmt" "github.com/gin-gonic/gin" ) func main() { r := gin.Default() r.GET("/", func(context *gin.Context) { // 查询字符串映射 (http://1 阅读全文
posted @ 2021-10-27 14:44 专职 阅读(87) 评论(0) 推荐(0) 编辑
摘要: 1. 一般通过调用 c.Request.Body 方法绑定数据,但不能多次调用这个方法。 package main import ( "fmt" "github.com/gin-gonic/gin" ) type FormA struct { Foo string `form:"foo" json: 阅读全文
posted @ 2021-10-27 13:53 专职 阅读(402) 评论(0) 推荐(0) 编辑
摘要: package main import ( "fmt" "github.com/gin-gonic/gin" "net/http" "time" ) func main() { router := gin.New() // LoggerWithFormatter middleware will wr 阅读全文
posted @ 2021-10-27 10:51 专职 阅读(228) 评论(0) 推荐(0) 编辑
摘要: package main import ( "github.com/gin-gonic/gin" "io" "os" ) func main() { // 禁用控制台颜色,将日志写入文件时不需要控制台颜色 gin.DisableConsoleColor() // 记录日志到文件 f, _ := os 阅读全文
posted @ 2021-10-26 17:59 专职 阅读(761) 评论(0) 推荐(0) 编辑
摘要: 1. 简单用法 package main import ( "github.com/gin-contrib/multitemplate" "github.com/gin-gonic/gin" "path/filepath" ) func createMyRender() multitemplate. 阅读全文
posted @ 2021-10-26 16:59 专职 阅读(1171) 评论(0) 推荐(0) 编辑
摘要: package main import ( "fmt" "github.com/gin-gonic/gin" "log" "time" ) func main() { // 当在中间件或handler启动新的goroutine时, 不能使用原始的上下文,必须使用只读的副本 r := gin.Defa 阅读全文
posted @ 2021-10-26 13:59 专职 阅读(429) 评论(0) 推荐(0) 编辑
摘要: Go 语言中会使用到的 25 个关键字或保留字: 1. 程序声明 import 导入 package 包 2. 程序实体声明和定义 chan 通道 var 变量声明 const 常量声明 func 用于定义函数和方法 interface 定义接口 map 字典/map struct 定义数据类型 t 阅读全文
posted @ 2021-10-24 11:48 专职 阅读(322) 评论(0) 推荐(0) 编辑
摘要: package main import ( "github.com/gin-gonic/gin" "log" ) type Person struct{ Name string `form:"name" binding:"required" json:"name"` Address string ` 阅读全文
posted @ 2021-10-22 16:08 专职 阅读(79) 评论(0) 推荐(0) 编辑
摘要: package main import ( "fmt" "github.com/gin-gonic/gin" ) func main() { // 新建一个没有任何默认中间件的路由 router := gin.New() // Logger 中间件将日志写入 gin.DefaultWriter,即使 阅读全文
posted @ 2021-10-22 15:30 专职 阅读(222) 评论(0) 推荐(0) 编辑
摘要: package mainimport ( "github.com/gin-gonic/gin" "net/http")// 模拟一些私人数据var secrets = gin.H{ "foo": gin.H{"email": "1341935532@qq.com", "phone": 1531306 阅读全文
posted @ 2021-10-22 11:34 专职 阅读(482) 评论(0) 推荐(0) 编辑
上一页 1 ··· 29 30 31 32 33 34 35 36 37 ··· 40 下一页