chore: bump golangci-lint to v1.58.0
All checks were successful
ci/woodpecker/push/govulncheck Pipeline was successful
ci/woodpecker/push/test Pipeline was successful

This commit is contained in:
Dawid Wysokiński 2024-05-04 06:57:03 +02:00
parent 68b715306d
commit d05d7aaacb
Signed by: Kichiyaki
GPG Key ID: B5445E357FB8B892
10 changed files with 30 additions and 28 deletions

View File

@ -57,10 +57,12 @@ linters:
- inamedparam - inamedparam
- sloglint - sloglint
- revive - revive
- gomnd - mnd
- forbidigo - forbidigo
- copyloopvar - copyloopvar
- intrange - intrange
- fatcontext
- canonicalheader
linters-settings: linters-settings:
gocyclo: gocyclo:
@ -123,7 +125,7 @@ linters-settings:
enable-all: true enable-all: true
sloglint: sloglint:
attr-only: true attr-only: true
gomnd: mnd:
ignored-functions: ignored-functions:
- strconv.FormatInt - strconv.FormatInt
- strconv.ParseInt - strconv.ParseInt
@ -507,7 +509,7 @@ issues:
text: add-constant text: add-constant
- path: bun/migrations - path: bun/migrations
linters: linters:
- gochecknoinits - init
- linters: - linters:
- lll - lll
source: "^//go:generate " source: "^//go:generate "

View File

@ -6,7 +6,7 @@ repos:
stages: [commit-msg] stages: [commit-msg]
additional_dependencies: ["@commitlint/config-conventional"] additional_dependencies: ["@commitlint/config-conventional"]
- repo: https://github.com/golangci/golangci-lint - repo: https://github.com/golangci/golangci-lint
rev: v1.57.2 rev: v1.58.0
hooks: hooks:
- id: golangci-lint - id: golangci-lint
- repo: https://github.com/hadolint/hadolint - repo: https://github.com/hadolint/hadolint

View File

@ -42,7 +42,7 @@ steps:
- go test -race -coverprofile=coverage.txt -covermode=atomic ./... - go test -race -coverprofile=coverage.txt -covermode=atomic ./...
lint: lint:
image: golangci/golangci-lint:v1.57 image: golangci/golangci-lint:v1.58
pull: true pull: true
depends_on: depends_on:
- generate - generate

View File

@ -16,7 +16,7 @@ install-git-hooks:
.PHONY: install-golangci-lint .PHONY: install-golangci-lint
install-golangci-lint: install-golangci-lint:
@echo "Installing github.com/golangci/golangci-lint..." @echo "Installing github.com/golangci/golangci-lint..."
@(test -f $(GOLANGCI_LINT_PATH) && echo "github.com/golangci/golangci-lint is already installed. Skipping...") || curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GOBIN) v1.57.2 @(test -f $(GOLANGCI_LINT_PATH) && echo "github.com/golangci/golangci-lint is already installed. Skipping...") || curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GOBIN) v1.58.0
.PHONY: install-oapi-codegen .PHONY: install-oapi-codegen
install-oapi-codegen: install-oapi-codegen:

View File

@ -23,30 +23,30 @@ var (
} }
dbFlagMaxIdleConns = &cli.IntFlag{ dbFlagMaxIdleConns = &cli.IntFlag{
Name: "db.maxIdleConns", Name: "db.maxIdleConns",
Value: 2, //nolint:gomnd Value: 2, //nolint:mnd
EnvVars: []string{"DB_MAX_IDLE_CONNS"}, EnvVars: []string{"DB_MAX_IDLE_CONNS"},
Usage: "https://pkg.go.dev/database/sql#DB.SetMaxIdleConns", Usage: "https://pkg.go.dev/database/sql#DB.SetMaxIdleConns",
} }
dbFlagMaxOpenConns = &cli.IntFlag{ dbFlagMaxOpenConns = &cli.IntFlag{
Name: "db.maxOpenConns", Name: "db.maxOpenConns",
Value: runtime.NumCPU() * 4, //nolint:gomnd Value: runtime.NumCPU() * 4, //nolint:mnd
EnvVars: []string{"DB_MAX_OPEN_CONNS"}, EnvVars: []string{"DB_MAX_OPEN_CONNS"},
Usage: "https://pkg.go.dev/database/sql#DB.SetMaxOpenConns", Usage: "https://pkg.go.dev/database/sql#DB.SetMaxOpenConns",
} }
dbFlagConnMaxLifetime = &cli.DurationFlag{ dbFlagConnMaxLifetime = &cli.DurationFlag{
Name: "db.connMaxLifetime", Name: "db.connMaxLifetime",
Value: 30 * time.Minute, //nolint:gomnd Value: 30 * time.Minute, //nolint:mnd
EnvVars: []string{"DB_CONN_MAX_LIFETIME"}, EnvVars: []string{"DB_CONN_MAX_LIFETIME"},
Usage: "https://pkg.go.dev/database/sql#DB.SetConnMaxLifetime", Usage: "https://pkg.go.dev/database/sql#DB.SetConnMaxLifetime",
} }
dbFlagReadTimeout = &cli.DurationFlag{ dbFlagReadTimeout = &cli.DurationFlag{
Name: "db.readTimeout", Name: "db.readTimeout",
Value: 10 * time.Second, //nolint:gomnd Value: 10 * time.Second, //nolint:mnd
EnvVars: []string{"DB_READ_TIMEOUT"}, EnvVars: []string{"DB_READ_TIMEOUT"},
} }
dbFlagWriteTimeout = &cli.DurationFlag{ dbFlagWriteTimeout = &cli.DurationFlag{
Name: "db.writeTimeout", Name: "db.writeTimeout",
Value: 5 * time.Second, //nolint:gomnd Value: 5 * time.Second, //nolint:mnd
EnvVars: []string{"DB_WRITE_TIMEOUT"}, EnvVars: []string{"DB_WRITE_TIMEOUT"},
} }
dbFlags = []cli.Flag{ dbFlags = []cli.Flag{

View File

@ -26,18 +26,18 @@ var (
apiServerFlagPort = &cli.UintFlag{ apiServerFlagPort = &cli.UintFlag{
Name: "api.port", Name: "api.port",
EnvVars: []string{"API_PORT"}, EnvVars: []string{"API_PORT"},
Value: 9234, //nolint:gomnd Value: 9234, //nolint:mnd
} }
apiServerFlagHandlerTimeout = &cli.DurationFlag{ apiServerFlagHandlerTimeout = &cli.DurationFlag{
Name: "api.handlerTimeout", Name: "api.handlerTimeout",
EnvVars: []string{"API_HANDLER_TIMEOUT"}, EnvVars: []string{"API_HANDLER_TIMEOUT"},
Value: 5 * time.Second, //nolint:gomnd Value: 5 * time.Second, //nolint:mnd
Usage: "https://pkg.go.dev/net/http#TimeoutHandler", Usage: "https://pkg.go.dev/net/http#TimeoutHandler",
} }
apiServerFlagReadTimeout = &cli.DurationFlag{ apiServerFlagReadTimeout = &cli.DurationFlag{
Name: "api.readTimeout", Name: "api.readTimeout",
EnvVars: []string{"API_READ_TIMEOUT"}, EnvVars: []string{"API_READ_TIMEOUT"},
Value: 5 * time.Second, //nolint:gomnd Value: 5 * time.Second, //nolint:mnd
} }
apiServerFlagReadHeaderTimeout = &cli.DurationFlag{ apiServerFlagReadHeaderTimeout = &cli.DurationFlag{
Name: "api.readHeaderTimeout", Name: "api.readHeaderTimeout",
@ -47,17 +47,17 @@ var (
apiServerFlagWriteTimeout = &cli.DurationFlag{ apiServerFlagWriteTimeout = &cli.DurationFlag{
Name: "api.writeTimeout", Name: "api.writeTimeout",
EnvVars: []string{"API_WRITE_TIMEOUT"}, EnvVars: []string{"API_WRITE_TIMEOUT"},
Value: 10 * time.Second, //nolint:gomnd Value: 10 * time.Second, //nolint:mnd
} }
apiServerFlagIdleTimeout = &cli.DurationFlag{ apiServerFlagIdleTimeout = &cli.DurationFlag{
Name: "api.idleTimeout", Name: "api.idleTimeout",
EnvVars: []string{"API_IDLE_TIMEOUT"}, EnvVars: []string{"API_IDLE_TIMEOUT"},
Value: 180 * time.Second, //nolint:gomnd Value: 180 * time.Second, //nolint:mnd
} }
apiServerFlagShutdownTimeout = &cli.DurationFlag{ apiServerFlagShutdownTimeout = &cli.DurationFlag{
Name: "api.shutdownTimeout", Name: "api.shutdownTimeout",
EnvVars: []string{"API_SHUTDOWN_TIMEOUT"}, EnvVars: []string{"API_SHUTDOWN_TIMEOUT"},
Value: 10 * time.Second, //nolint:gomnd Value: 10 * time.Second, //nolint:mnd
} }
apiServerFlagOpenAPIEnabled = &cli.BoolFlag{ apiServerFlagOpenAPIEnabled = &cli.BoolFlag{
Name: "api.openApi.enabled", Name: "api.openApi.enabled",

View File

@ -20,7 +20,7 @@ var (
} }
twSvcFlagTimeout = &cli.DurationFlag{ twSvcFlagTimeout = &cli.DurationFlag{
Name: "tw.timeout", Name: "tw.timeout",
Value: 10 * time.Second, //nolint:gomnd Value: 10 * time.Second, //nolint:mnd
EnvVars: []string{"TW_TIMEOUT"}, EnvVars: []string{"TW_TIMEOUT"},
Usage: "https://pkg.go.dev/net/http#Client.Timeout", Usage: "https://pkg.go.dev/net/http#Client.Timeout",
} }

6
go.mod
View File

@ -26,7 +26,7 @@ require (
github.com/uptrace/bun/driver/pgdriver v1.2.1 github.com/uptrace/bun/driver/pgdriver v1.2.1
github.com/uptrace/bun/driver/sqliteshim v1.2.1 github.com/uptrace/bun/driver/sqliteshim v1.2.1
github.com/uptrace/bun/extra/bundebug v1.2.1 github.com/uptrace/bun/extra/bundebug v1.2.1
github.com/urfave/cli/v2 v2.27.1 github.com/urfave/cli/v2 v2.27.2
go.uber.org/automaxprocs v1.5.3 go.uber.org/automaxprocs v1.5.3
golang.org/x/sync v0.7.0 golang.org/x/sync v0.7.0
gopkg.in/yaml.v3 v3.0.1 gopkg.in/yaml.v3 v3.0.1
@ -40,7 +40,7 @@ require (
github.com/apapsch/go-jsonmerge/v2 v2.0.0 // indirect github.com/apapsch/go-jsonmerge/v2 v2.0.0 // indirect
github.com/cenkalti/backoff/v3 v3.2.2 // indirect github.com/cenkalti/backoff/v3 v3.2.2 // indirect
github.com/containerd/continuity v0.3.0 // indirect github.com/containerd/continuity v0.3.0 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect github.com/cpuguy83/go-md2man/v2 v2.0.4 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect github.com/davecgh/go-spew v1.1.1 // indirect
github.com/docker/cli v20.10.17+incompatible // indirect github.com/docker/cli v20.10.17+incompatible // indirect
github.com/docker/docker v20.10.7+incompatible // indirect github.com/docker/docker v20.10.7+incompatible // indirect
@ -86,7 +86,7 @@ require (
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f // indirect github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f // indirect
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
github.com/xeipuuv/gojsonschema v1.2.0 // indirect github.com/xeipuuv/gojsonschema v1.2.0 // indirect
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect github.com/xrash/smetrics v0.0.0-20240312152122-5f08fbb34913 // indirect
golang.org/x/crypto v0.21.0 // indirect golang.org/x/crypto v0.21.0 // indirect
golang.org/x/mod v0.16.0 // indirect golang.org/x/mod v0.16.0 // indirect
golang.org/x/sys v0.18.0 // indirect golang.org/x/sys v0.18.0 // indirect

12
go.sum
View File

@ -30,8 +30,8 @@ github.com/containerd/continuity v0.3.0 h1:nisirsYROK15TAMVukJOUyGJjz4BNQJBVsNvA
github.com/containerd/continuity v0.3.0/go.mod h1:wJEAIwKOm/pBZuBd0JmeTvnLquTB1Ag8espWhkykbPM= github.com/containerd/continuity v0.3.0/go.mod h1:wJEAIwKOm/pBZuBd0JmeTvnLquTB1Ag8espWhkykbPM=
github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w= github.com/cpuguy83/go-md2man/v2 v2.0.4 h1:wfIWP927BUkWJb2NmU/kNDYIBTh/ziUX91+lVfRxZq4=
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/creack/pty v1.1.11 h1:07n33Z8lZxZ2qwegKbObQohDhXDQxiMMz1NOUGYlesw= github.com/creack/pty v1.1.11 h1:07n33Z8lZxZ2qwegKbObQohDhXDQxiMMz1NOUGYlesw=
github.com/creack/pty v1.1.11/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/creack/pty v1.1.11/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/cyphar/filepath-securejoin v0.2.3/go.mod h1:aPGpWjXOXUn2NCNjFvBE6aRxGGx79pTxQpKOJNYHHl4= github.com/cyphar/filepath-securejoin v0.2.3/go.mod h1:aPGpWjXOXUn2NCNjFvBE6aRxGGx79pTxQpKOJNYHHl4=
@ -206,8 +206,8 @@ github.com/uptrace/bun/driver/sqliteshim v1.2.1/go.mod h1:oJtOPSCDdDHgNw/0jwIGr+
github.com/uptrace/bun/extra/bundebug v1.2.1 h1:85MYpX3QESYI02YerKxUi1CD9mHuLrc2BXs1eOCtQus= github.com/uptrace/bun/extra/bundebug v1.2.1 h1:85MYpX3QESYI02YerKxUi1CD9mHuLrc2BXs1eOCtQus=
github.com/uptrace/bun/extra/bundebug v1.2.1/go.mod h1:sfGKIi0HSGxsTC/sgIHGwpnYduHHYhdMeOIwurgSY+Y= github.com/uptrace/bun/extra/bundebug v1.2.1/go.mod h1:sfGKIi0HSGxsTC/sgIHGwpnYduHHYhdMeOIwurgSY+Y=
github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
github.com/urfave/cli/v2 v2.27.1 h1:8xSQ6szndafKVRmfyeUMxkNUJQMjL1F2zmsZ+qHpfho= github.com/urfave/cli/v2 v2.27.2 h1:6e0H+AkS+zDckwPCUrZkKX38mRaau4nL2uipkJpbkcI=
github.com/urfave/cli/v2 v2.27.1/go.mod h1:8qnjx1vcq5s2/wpsqoZFndg2CE5tNFyrTvS6SinrnYQ= github.com/urfave/cli/v2 v2.27.2/go.mod h1:g0+79LmHHATl7DAcHO99smiR/T7uGLw84w8Y42x+4eM=
github.com/vishvananda/netlink v1.1.0/go.mod h1:cTgwzPIzzgDAYoQrMm0EdrjRUBkTqKYppBueQtXaqoE= github.com/vishvananda/netlink v1.1.0/go.mod h1:cTgwzPIzzgDAYoQrMm0EdrjRUBkTqKYppBueQtXaqoE=
github.com/vishvananda/netns v0.0.0-20191106174202-0a2b9b5464df/go.mod h1:JP3t17pCcGlemwknint6hfoeCVQrEMVwxRLRjXpq+BU= github.com/vishvananda/netns v0.0.0-20191106174202-0a2b9b5464df/go.mod h1:JP3t17pCcGlemwknint6hfoeCVQrEMVwxRLRjXpq+BU=
github.com/vmihailenco/msgpack/v5 v5.4.1 h1:cQriyiUvjTwOHg8QZaPihLWeRAAVoCpE00IUPn0Bjt8= github.com/vmihailenco/msgpack/v5 v5.4.1 h1:cQriyiUvjTwOHg8QZaPihLWeRAAVoCpE00IUPn0Bjt8=
@ -220,8 +220,8 @@ github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 h1:EzJWgHo
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ= github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ=
github.com/xeipuuv/gojsonschema v1.2.0 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17UxZ74= github.com/xeipuuv/gojsonschema v1.2.0 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17UxZ74=
github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y= github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y=
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU= github.com/xrash/smetrics v0.0.0-20240312152122-5f08fbb34913 h1:+qGGcbkzsfDQNPPe9UDgpxAWQrhbbBXOYJFQDq/dtJw=
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8= github.com/xrash/smetrics v0.0.0-20240312152122-5f08fbb34913/go.mod h1:4aEEwZQutDLsQv2Deui4iYQ6DWTxR14g6m8Wv88+Xqk=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
go.uber.org/automaxprocs v1.5.3 h1:kWazyxZUrS3Gs4qUpbwo5kEIMGe/DAvi5Z4tl2NW4j8= go.uber.org/automaxprocs v1.5.3 h1:kWazyxZUrS3Gs4qUpbwo5kEIMGe/DAvi5Z4tl2NW4j8=

View File

@ -47,7 +47,7 @@ func Logger(logger Slogger, opts ...Option) func(next http.Handler) http.Handler
slog.String("httpRequest.ip", cfg.ipExtractor(r)), slog.String("httpRequest.ip", cfg.ipExtractor(r)),
slog.Int("httpResponse.status", status), slog.Int("httpResponse.status", status),
slog.Int("httpResponse.bytes", ww.BytesWritten()), slog.Int("httpResponse.bytes", ww.BytesWritten()),
//nolint:gomnd //nolint:mnd
slog.Float64("httpResponse.duration", float64(end.Sub(start).Nanoseconds())/1000000.0), // in milliseconds slog.Float64("httpResponse.duration", float64(end.Sub(start).Nanoseconds())/1000000.0), // in milliseconds
) )
}) })