From 7fe6e7077c605ecd4652da33569e97b6defd380c Mon Sep 17 00:00:00 2001 From: Young Xu Date: Sat, 6 Apr 2024 02:13:15 +0800 Subject: [PATCH] fix: router --- router_register.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/router_register.go b/router_register.go index 2546489..0719ccc 100644 --- a/router_register.go +++ b/router_register.go @@ -345,7 +345,7 @@ func (r *Register) bindAndValidate(c *gin.Context, req interface{}) error { return nil } bodyBytes, _ := io.ReadAll(c.Request.Body) - c.Request.Body.Close() + _ = c.Request.Body.Close() c.Request.Body = io.NopCloser(bytes.NewBuffer(bodyBytes)) // 如果只有query有数据,则获取query中的参数 @@ -404,7 +404,8 @@ func (r *Register) bindAndValidate(c *gin.Context, req interface{}) error { err := validate.Struct(req) if err != nil { - if _, ok := err.(*validator.InvalidValidationError); ok { + var invalidValidationError *validator.InvalidValidationError + if errors.As(err, &invalidValidationError) { logrus.Errorf("validate failed: %+v", err) return err }