From fddadbfeb015324e07e12db4195857abb7522d1a Mon Sep 17 00:00:00 2001 From: Leon Clark Date: Thu, 14 Mar 2024 18:43:26 -0700 Subject: [PATCH 1/2] update to go 1.22 --- .github/workflows/build.yml | 6 +++--- .golangci.yaml | 2 +- Makefile | 2 +- go.mod | 16 ++++++++-------- go.sum | 28 ++++++++++++++-------------- 5 files changed, 27 insertions(+), 27 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7bdacbe..eb3adad 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -7,12 +7,12 @@ jobs: build-test: strategy: matrix: - go-version: [ 1.21 ] + go-version: [ 1.22 ] os: [ ubuntu-latest ] runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v3 - - uses: actions/setup-go@v4 + - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 with: go-version: ${{ matrix.go-version }} diff --git a/.golangci.yaml b/.golangci.yaml index 8947423..1719c4f 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -1,5 +1,5 @@ run: - go: 1.21 + go: 1.22 deadline: 10m skip-dirs: - temp diff --git a/Makefile b/Makefile index fd8b450..3d5a8d2 100644 --- a/Makefile +++ b/Makefile @@ -9,7 +9,7 @@ cover: go tool cover -html=cp.out tidy: - go mod tidy -compat=1.21 + go mod tidy update: updateAll tidy diff --git a/go.mod b/go.mod index 82ba17c..59845cd 100644 --- a/go.mod +++ b/go.mod @@ -1,14 +1,14 @@ module github.com/bir/iken -go 1.21 +go 1.22 require ( - github.com/go-chi/chi/v5 v5.0.11 - github.com/google/uuid v1.5.0 - github.com/jackc/pgx/v5 v5.5.1 + github.com/go-chi/chi/v5 v5.0.12 + github.com/google/uuid v1.6.0 + github.com/jackc/pgx/v5 v5.5.5 github.com/mitchellh/mapstructure v1.5.0 github.com/pkg/errors v0.9.1 - github.com/rs/zerolog v1.31.0 + github.com/rs/zerolog v1.32.0 github.com/spf13/cast v1.6.0 github.com/spf13/viper v1.18.2 github.com/stretchr/testify v1.8.4 @@ -32,9 +32,9 @@ require ( github.com/spf13/pflag v1.0.5 // indirect github.com/subosito/gotenv v1.6.0 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/crypto v0.17.0 // indirect - golang.org/x/exp v0.0.0-20231226003508-02704c960a9b // indirect - golang.org/x/sys v0.15.0 // indirect + golang.org/x/crypto v0.21.0 // indirect + golang.org/x/exp v0.0.0-20240314144324-c7f7c6466f7f // indirect + golang.org/x/sys v0.18.0 // indirect golang.org/x/text v0.14.0 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect diff --git a/go.sum b/go.sum index 2a3d485..895f58e 100644 --- a/go.sum +++ b/go.sum @@ -7,21 +7,21 @@ github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHk github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0= github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA= github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM= -github.com/go-chi/chi/v5 v5.0.11 h1:BnpYbFZ3T3S1WMpD79r7R5ThWX40TaFB7L31Y8xqSwA= -github.com/go-chi/chi/v5 v5.0.11/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8= +github.com/go-chi/chi/v5 v5.0.12 h1:9euLV5sTrTNTRUU9POmDUvfxyj6LAABLUcEWO+JJb4s= +github.com/go-chi/chi/v5 v5.0.12/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/uuid v1.5.0 h1:1p67kYwdtXjb0gL0BPiP1Av9wiZPo5A8z2cWkTZ+eyU= -github.com/google/uuid v1.5.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM= github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg= github.com/jackc/pgservicefile v0.0.0-20231201235250-de7065d80cb9 h1:L0QtFUgDarD7Fpv9jeVMgy/+Ec0mtnmYuImjTz6dtDA= github.com/jackc/pgservicefile v0.0.0-20231201235250-de7065d80cb9/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM= -github.com/jackc/pgx/v5 v5.5.1 h1:5I9etrGkLrN+2XPCsi6XLlV5DITbSL/xBZdmAxFcXPI= -github.com/jackc/pgx/v5 v5.5.1/go.mod h1:Ig06C2Vu0t5qXC60W8sqIthScaEnFvojjj9dSljmHRA= +github.com/jackc/pgx/v5 v5.5.5 h1:amBjrZVmksIdNjxGW/IiIMzxMKZFelXbUoPNb+8sjQw= +github.com/jackc/pgx/v5 v5.5.5/go.mod h1:ez9gk+OAat140fv9ErkZDYFWmXLfV+++K0uAOiwgm1A= github.com/jackc/puddle/v2 v2.2.1 h1:RhxXJtFG022u4ibrCSMSiu5aOq1i77R3OHKNJj77OAk= github.com/jackc/puddle/v2 v2.2.1/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= @@ -48,8 +48,8 @@ github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= -github.com/rs/zerolog v1.31.0 h1:FcTR3NnLWW+NnTwwhFWiJSZr4ECLpqCm6QsEnyvbV4A= -github.com/rs/zerolog v1.31.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss= +github.com/rs/zerolog v1.32.0 h1:keLypqrlIjaFsbmJOBdB/qvyF8KEtCWHwobLp5l/mQ0= +github.com/rs/zerolog v1.32.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss= github.com/sagikazarmark/locafero v0.4.0 h1:HApY1R9zGo4DBgr7dqsTH/JJxLTTsOt7u6keLGt6kNQ= github.com/sagikazarmark/locafero v0.4.0/go.mod h1:Pe1W6UlPYUk/+wc/6KFhbORCfqzgYEpgQ3O5fPuL3H4= github.com/sagikazarmark/slog-shim v0.1.0 h1:diDBnUNK9N/354PgrxMywXnAwEr1QZcOr6gto+ugjYE= @@ -77,17 +77,17 @@ github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8 github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU= go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= -golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= -golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= -golang.org/x/exp v0.0.0-20231226003508-02704c960a9b h1:kLiC65FbiHWFAOu+lxwNPujcsl8VYyTYYEZnsOO1WK4= -golang.org/x/exp v0.0.0-20231226003508-02704c960a9b/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI= +golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= +golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= +golang.org/x/exp v0.0.0-20240314144324-c7f7c6466f7f h1:3CW0unweImhOzd5FmYuRsD4Y4oQFKZIjAnKbjV4WIrw= +golang.org/x/exp v0.0.0-20240314144324-c7f7c6466f7f/go.mod h1:CxmFvTBINI24O/j8iY7H1xHzx2i4OsyguNBmN/uPtqc= golang.org/x/sync v0.5.0 h1:60k92dhOjHxJkrqnwsfl8KuaHbn/5dl0lUPUklKo3qE= golang.org/x/sync v0.5.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= -golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= +golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= From ae4f5b3b909a3817235cb9eaad56fd5240575d41 Mon Sep 17 00:00:00 2001 From: Leon Clark Date: Thu, 14 Mar 2024 18:46:15 -0700 Subject: [PATCH 2/2] lint fixes --- errs/cause.go | 4 ++-- errs/stack.go | 2 +- httplog/request.go | 8 +++++--- httputil/rapidoc.go | 2 +- httputil/wrap_writer.go | 4 ++-- 5 files changed, 11 insertions(+), 9 deletions(-) diff --git a/errs/cause.go b/errs/cause.go index f477e09..ae50a92 100644 --- a/errs/cause.go +++ b/errs/cause.go @@ -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 } diff --git a/errs/stack.go b/errs/stack.go index 5e53486..c08077c 100644 --- a/errs/stack.go +++ b/errs/stack.go @@ -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 } diff --git a/httplog/request.go b/httplog/request.go index 2926892..b95f326 100644 --- a/httplog/request.go +++ b/httplog/request.go @@ -74,6 +74,7 @@ func RequestLogger(shouldLog FnShouldLog) func(http.Handler) http.Handler { //no } var responseBuffer *bytes.Buffer + wrappedWriter := httputil.WrapWriter(w) if logResponse { @@ -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) diff --git a/httputil/rapidoc.go b/httputil/rapidoc.go index 82152c0..c697e22 100644 --- a/httputil/rapidoc.go +++ b/httputil/rapidoc.go @@ -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) diff --git a/httputil/wrap_writer.go b/httputil/wrap_writer.go index 54af9a4..1eebbe1 100644 --- a/httputil/wrap_writer.go +++ b/httputil/wrap_writer.go @@ -2,7 +2,7 @@ package httputil import ( "bufio" - "fmt" + "errors" "io" "net" "net/http" @@ -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)