fix: golanglint

This commit is contained in:
Flc゛ 2023-04-26 22:37:48 +08:00
parent fe989b6a6f
commit 72838a5d2e

View File

@ -665,7 +665,7 @@ func (c *Context) BindHeader(obj any) error {
// It will abort the request with HTTP 400 if any error occurs.
func (c *Context) BindUri(obj any) error {
if err := c.ShouldBindUri(obj); err != nil {
c.AbortWithError(http.StatusBadRequest, err).SetType(ErrorTypeBind) //nolint: errcheck
c.AbortWithError(http.StatusBadRequest, err).SetType(ErrorTypeBind) // nolint: errcheck
return err
}
return nil
@ -676,7 +676,7 @@ func (c *Context) BindUri(obj any) error {
// See the binding package.
func (c *Context) MustBindWith(obj any, b binding.Binding) error {
if err := c.ShouldBindWith(obj, b); err != nil {
c.AbortWithError(http.StatusBadRequest, err).SetType(ErrorTypeBind) //nolint: errcheck
c.AbortWithError(http.StatusBadRequest, err).SetType(ErrorTypeBind) // nolint: errcheck
return err
}
return nil
@ -1075,6 +1075,9 @@ func (c *Context) SSEvent(name string, message any) {
// indicates "Is client disconnected in middle of stream"
func (c *Context) Stream(step func(w io.Writer) bool) bool {
w := c.Writer
if _, ok := w.(http.CloseNotifier); !ok {
return false
}
clientGone := w.CloseNotify()
for {
select {
@ -1082,7 +1085,9 @@ func (c *Context) Stream(step func(w io.Writer) bool) bool {
return true
default:
keepOpen := step(w)
w.Flush()
if flusher, ok := w.(http.Flusher); ok {
flusher.Flush()
}
if !keepOpen {
return false
}
@ -1130,7 +1135,7 @@ func (c *Context) Negotiate(code int, config Negotiate) {
c.TOML(code, data)
default:
c.AbortWithError(http.StatusNotAcceptable, errors.New("the accepted formats are not offered by the server")) //nolint: errcheck
c.AbortWithError(http.StatusNotAcceptable, errors.New("the accepted formats are not offered by the server")) // nolint: errcheck
}
}