Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
OneOfOne committed Jul 9, 2024
1 parent 6fffdc7 commit efdfede
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 46 deletions.
10 changes: 5 additions & 5 deletions gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,10 @@ func handleOutOnly[CodecT Codec, Resp any, HandlerFn func(ctx *Context) (resp Re
return NewResponse[CodecT](resp)
}
if respBytes {
ctx.Write(any(resp).([]byte))
_, _ = ctx.Write(any(resp).([]byte))
return nil
}
c.Encode(ctx, resp)
_ = c.Encode(ctx, resp)
return nil
})
}
Expand Down Expand Up @@ -119,10 +119,10 @@ func handleInOut[CodecT Codec, Req, Resp any, HandlerFn func(ctx *Context, reqBo
return NewResponse[CodecT](resp)
}
if respBytes {
ctx.Write(any(resp).([]byte))
_, _ = ctx.Write(any(resp).([]byte))
return nil
}
c.Encode(ctx, resp)
_ = c.Encode(ctx, resp)
return nil
})
}
Expand All @@ -134,6 +134,6 @@ func handleError[C Codec](ctx *Context, e error, wrapResp bool) Response {
return NewErrorResponse[C](err.Status(), err)
}
ctx.WriteHeader(err.Status())
c.Encode(ctx, getError(err))
_ = c.Encode(ctx, getError(err))
return nil
}
6 changes: 3 additions & 3 deletions group.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func (g *Group) Static(path, localPath string, allowListing bool) Route {

func (g *Group) StaticFile(path, localPath string) Route {
return g.AddRoute(http.MethodGet, path, func(ctx *Context) Response {
ctx.File(localPath)
_ = ctx.File(localPath)
return nil
})
}
Expand Down Expand Up @@ -146,7 +146,7 @@ func (ghc *groupHandlerChain) Serve(rw http.ResponseWriter, req *http.Request, p
mwIdx++
if r := h(ctx); r != nil {
if r != Break {
r.WriteToCtx(ctx)
_ = r.WriteToCtx(ctx)
} else {
ctx.next = nil
}
Expand All @@ -165,7 +165,7 @@ func (ghc *groupHandlerChain) Serve(rw http.ResponseWriter, req *http.Request, p
hIdx++
if r := h(ctx); r != nil {
if r != Break {
r.WriteToCtx(ctx)
_ = r.WriteToCtx(ctx)
}
break
}
Expand Down
30 changes: 0 additions & 30 deletions keepalive.go

This file was deleted.

2 changes: 1 addition & 1 deletion mw.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func LogRequests(logJSONRequests bool) Handler {
switch m := req.Method; m {
case http.MethodPost, http.MethodPut, http.MethodPatch:
var buf bytes.Buffer
io.Copy(&buf, req.Body)
_, _ = io.Copy(&buf, req.Body)
req.Body.Close()
req.Body = io.NopCloser(&buf)
j, _ := internal.Marshal(req.Header)
Expand Down
2 changes: 0 additions & 2 deletions ratelimit.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,6 @@ type Limiters struct {
maxPerSecond int
maxPerMinute int
maxPerHour int

mux sync.RWMutex
}

func (ls *Limiters) clean() {
Expand Down
2 changes: 1 addition & 1 deletion resp.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func CachedResponse(code int, contentType string, body any) Response {
b = otk.UnsafeBytes(v.String())
case io.Reader:
var buf bytes.Buffer
io.Copy(&buf, v)
_, _ = io.Copy(&buf, v)
b = buf.Bytes()
default:
v = otk.UnsafeBytes(fmt.Sprintf("%v", v))
Expand Down
6 changes: 3 additions & 3 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ var DefaultPanicHandler = func(ctx *Context, v any, fr *oerrs.Frame) {
msg, info := fmt.Sprintf("PANIC in %s %s: %v", ctx.Req.Method, ctx.Path(), v), fmt.Sprintf("at %s %s:%d", fr.Function, fr.File, fr.Line)
ctx.Logf("%s (%s)", msg, info)
resp := NewJSONErrorResponse(500, "internal server error")
ctx.Encode(500, resp)
_ = ctx.Encode(500, resp)
}

var noopLogger = log.New(io.Discard, "", 0)
Expand Down Expand Up @@ -77,7 +77,7 @@ func NewWithOpts(opts *Options) *Server {
return
}

RespNotFound.WriteToCtx(&Context{
_ = RespNotFound.WriteToCtx(&Context{
Req: req,
ResponseWriter: w,
})
Expand Down Expand Up @@ -141,7 +141,7 @@ func (s *Server) newHTTPServer(ctx context.Context, addr string, forceHTTP2 bool

go func() {
<-ctx.Done()
srv.Shutdown(ctx)
_ = srv.Shutdown(ctx)
}()

return srv
Expand Down
1 change: 0 additions & 1 deletion utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ func StaticDirWithLimit(dir, paramName string, limit int) Handler {
type noListingDir string

func (d noListingDir) Open(name string) (f http.File, err error) {
const indexName = "/index.html"
hd := http.Dir(d)

if f, err = hd.Open(name); err != nil {
Expand Down

0 comments on commit efdfede

Please sign in to comment.