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 }