上一页 1 ··· 47 48 49 50 51 52 53 54 55 ··· 169 下一页
摘要: 一,什么是context? 1,context是什么? context是 goroutine(协程) 的上下文,包含 goroutine 的运行状态、环境、现场等信息。context 主要用来在 goroutine 之间传递上下文信息,包括:取消信号、超时时间、截止时间、k-v 等。 2,conte 阅读全文
posted @ 2025-02-09 19:16 刘宏缔的架构森林 阅读(221) 评论(0) 推荐(0)
摘要: 一,创建middleware $ php bin/hyperf.php gen:middleware AccesslogMiddleware App\Middleware\AccesslogMiddleware created successfully. 二,配置一个日志 config/autolo 阅读全文
posted @ 2025-02-09 19:16 刘宏缔的架构森林 阅读(130) 评论(0) 推荐(0)
摘要: 一,配置 config/autoload/exceptions.php <?php declare(strict_types=1); /** * This file is part of Hyperf. * * @link https://www.hyperf.io * @document http 阅读全文
posted @ 2025-02-09 19:15 刘宏缔的架构森林 阅读(143) 评论(1) 推荐(0)
摘要: 一,安装第三方库: $ go get -u gorm.io/gorm go: added github.com/jinzhu/inflection v1.0.0 go: added github.com/jinzhu/now v1.1.5 go: added gorm.io/gorm v1.25.1 阅读全文
posted @ 2025-02-02 12:38 刘宏缔的架构森林 阅读(76) 评论(0) 推荐(0)
摘要: 一,代码 1,global/validator.go package global import "github.com/go-playground/validator/v10" //存放GetMessages()方法 type Validator interface { GetMessages() 阅读全文
posted @ 2025-01-31 17:39 刘宏缔的架构森林 阅读(201) 评论(0) 推荐(0)
摘要: 一,安装第三方库: $ go get -u github.com/go-playground/validator/v10 go: downloading github.com/go-playground/validator/v10 v10.24.0 go: downloading github.co 阅读全文
posted @ 2025-01-31 15:02 刘宏缔的架构森林 阅读(41) 评论(0) 推荐(0)
摘要: 一,得到get参数 1,代码: //得到列表 func (ic *ImageController) List(c *gin.Context) { // 不带缺省值 a := c.Query("a") // 带缺省值 d := c.DefaultQuery("d", "dd") fmt.Println 阅读全文
posted @ 2025-01-31 13:04 刘宏缔的架构森林 阅读(50) 评论(0) 推荐(0)
摘要: 一,安装zap $ go get -u go.uber.org/zap go: downloading go.uber.org/zap v1.27.0 go: downloading go.uber.org/multierr v1.10.0 go: downloading go.uber.org/m 阅读全文
posted @ 2025-01-31 10:55 刘宏缔的架构森林 阅读(125) 评论(0) 推荐(0)
摘要: 一,代码: 1,routes/route.go package routes import ( "fmt" "github.com/gin-gonic/gin" "imagebank/controller" "imagebank/global" "runtime/debug" "time" ) fu 阅读全文
posted @ 2025-01-30 19:56 刘宏缔的架构森林 阅读(220) 评论(0) 推荐(0)
摘要: 一,目录结构: 二,代码: 1,controller/ImageController.go package controller import ( "github.com/gin-gonic/gin" "net/http" ) type ImageController struct{} func N 阅读全文
posted @ 2025-01-29 22:00 刘宏缔的架构森林 阅读(32) 评论(0) 推荐(0)
上一页 1 ··· 47 48 49 50 51 52 53 54 55 ··· 169 下一页