摘要: 一,安装第三方库: $ 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 刘宏缔的架构森林 阅读(8) 评论(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 刘宏缔的架构森林 阅读(5) 评论(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 刘宏缔的架构森林 阅读(2) 评论(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 刘宏缔的架构森林 阅读(4) 评论(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 刘宏缔的架构森林 阅读(4) 评论(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 刘宏缔的架构森林 阅读(10) 评论(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 刘宏缔的架构森林 阅读(6) 评论(0) 推荐(0) 编辑
摘要: 一,创建项目 创建目录: $ mkdir imagebank $ cd imagebank/ 创建项目: $ go mod init imagebank go: creating new go.mod: module imagebank 引入gin第三方库 liuhongdi@lhdpc:/data 阅读全文
posted @ 2025-01-29 16:01 刘宏缔的架构森林 阅读(5) 评论(0) 推荐(0) 编辑
摘要: 一,配置日志 在config/autoload/logger.php中增加一项对日志的配置: 'daily' => [ 'handler' => [ 'class' => Monolog\Handler\RotatingFileHandler::class, 'constructor' => [ ' 阅读全文
posted @ 2025-01-25 11:26 刘宏缔的架构森林 阅读(5) 评论(0) 推荐(0) 编辑
摘要: 一,创建controller $ php bin/hyperf.php gen:controller ImageController App\Controller\ImageController created successfully. 配置路由: Router::addGroup('/image 阅读全文
posted @ 2025-01-25 11:26 刘宏缔的架构森林 阅读(5) 评论(0) 推荐(0) 编辑