mirror of
https://github.com/gin-gonic/gin.git
synced 2025-10-16 05:16:35 +08:00
fix: golanglint
This commit is contained in:
parent
fe989b6a6f
commit
72838a5d2e
13
context.go
13
context.go
@ -665,7 +665,7 @@ func (c *Context) BindHeader(obj any) error {
|
|||||||
// It will abort the request with HTTP 400 if any error occurs.
|
// It will abort the request with HTTP 400 if any error occurs.
|
||||||
func (c *Context) BindUri(obj any) error {
|
func (c *Context) BindUri(obj any) error {
|
||||||
if err := c.ShouldBindUri(obj); err != nil {
|
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 err
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
@ -676,7 +676,7 @@ func (c *Context) BindUri(obj any) error {
|
|||||||
// See the binding package.
|
// See the binding package.
|
||||||
func (c *Context) MustBindWith(obj any, b binding.Binding) error {
|
func (c *Context) MustBindWith(obj any, b binding.Binding) error {
|
||||||
if err := c.ShouldBindWith(obj, b); err != nil {
|
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 err
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
@ -1075,6 +1075,9 @@ func (c *Context) SSEvent(name string, message any) {
|
|||||||
// indicates "Is client disconnected in middle of stream"
|
// indicates "Is client disconnected in middle of stream"
|
||||||
func (c *Context) Stream(step func(w io.Writer) bool) bool {
|
func (c *Context) Stream(step func(w io.Writer) bool) bool {
|
||||||
w := c.Writer
|
w := c.Writer
|
||||||
|
if _, ok := w.(http.CloseNotifier); !ok {
|
||||||
|
return false
|
||||||
|
}
|
||||||
clientGone := w.CloseNotify()
|
clientGone := w.CloseNotify()
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
@ -1082,7 +1085,9 @@ func (c *Context) Stream(step func(w io.Writer) bool) bool {
|
|||||||
return true
|
return true
|
||||||
default:
|
default:
|
||||||
keepOpen := step(w)
|
keepOpen := step(w)
|
||||||
w.Flush()
|
if flusher, ok := w.(http.Flusher); ok {
|
||||||
|
flusher.Flush()
|
||||||
|
}
|
||||||
if !keepOpen {
|
if !keepOpen {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@ -1130,7 +1135,7 @@ func (c *Context) Negotiate(code int, config Negotiate) {
|
|||||||
c.TOML(code, data)
|
c.TOML(code, data)
|
||||||
|
|
||||||
default:
|
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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user