Skip to content

Commit

Permalink
lint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
leclark committed Mar 15, 2024
1 parent fddadbf commit ae4f5b3
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 9 deletions.
4 changes: 2 additions & 2 deletions errs/cause.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ package errs
// This supports both Go 1.13+ style `UnWrap` and pkg.errors style
// `Cause` chaining.
func Cause(err error) error {
u, ok := err.(interface{ Unwrap() error }) //nolint:errorlint // false positive
u, ok := err.(interface{ Unwrap() error })
if ok {
return u.Unwrap() //nolint:wrapcheck // defeats the whole point
}

c, ok := err.(interface{ Cause() error }) //nolint:errorlint // false positive
c, ok := err.(interface{ Cause() error })
if ok {
return c.Cause() //nolint:wrapcheck // defeats the whole point
}
Expand Down
2 changes: 1 addition & 1 deletion errs/stack.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func (f Frame) String() string {
func ExtractStackFrame(err error) []Frame {
type stackTracer interface{ StackTrace() []uintptr }

stacker, ok := err.(stackTracer) //nolint:errorlint // false positive
stacker, ok := err.(stackTracer)
if !ok {
return nil
}
Expand Down
8 changes: 5 additions & 3 deletions httplog/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ func RequestLogger(shouldLog FnShouldLog) func(http.Handler) http.Handler { //no
}

var responseBuffer *bytes.Buffer

wrappedWriter := httputil.WrapWriter(w)

if logResponse {
Expand Down Expand Up @@ -112,15 +113,16 @@ func RequestLogger(shouldLog FnShouldLog) func(http.Handler) http.Handler { //no
}

logger := l.Logger()

var event *zerolog.Event

switch {
case status >= http.StatusInternalServerError:
event = logger.Error() //nolint
event = logger.Error()
case status >= http.StatusBadRequest:
event = logger.Warn() //nolint
event = logger.Warn()
default:
event = logger.Info() //nolint
event = logger.Info()
}

event.Msgf("%d %s %s", status, r.Method, r.URL)
Expand Down
2 changes: 1 addition & 1 deletion httputil/rapidoc.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func RapiDoc(opts RapiDocOpts) func(w http.ResponseWriter, r *http.Request) {
_ = tmpl.Execute(buf, opts)
b := buf.Bytes()

return func(w http.ResponseWriter, r *http.Request) {
return func(w http.ResponseWriter, _ *http.Request) {
w.Header().Set("Content-Type", "text/html; charset=utf-8")

_, _ = w.Write(b)
Expand Down
4 changes: 2 additions & 2 deletions httputil/wrap_writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package httputil

import (
"bufio"
"fmt"
"errors"
"io"
"net"
"net/http"
Expand Down Expand Up @@ -122,7 +122,7 @@ func (f *fancyWriter) Flush() {
f.basicWriter.Flush()
}

var ErrUnsupported = fmt.Errorf("not implemented")
var ErrUnsupported = errors.New("not implemented")

func (f *fancyWriter) Hijack() (net.Conn, *bufio.ReadWriter, error) {
hj, ok := f.basicWriter.ResponseWriter.(http.Hijacker)
Expand Down

0 comments on commit ae4f5b3

Please sign in to comment.