diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3ff8294..ad51516 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,10 +10,10 @@ jobs: strategy: matrix: - go-version: [ "1.21", "1.22" ] + go-version: [ "1.22", "1.23" ] runs-on: ubuntu-latest env: - GOLANGCI_LINT_VERSION: v1.56.1 + GOLANGCI_LINT_VERSION: v1.61.0 steps: - name: Install Go @@ -37,7 +37,6 @@ jobs: uses: golangci/golangci-lint-action@v6 with: version: ${{ env.GOLANGCI_LINT_VERSION }} - skip-pkg-cache: true args: --go ${{ matrix.go-version }} - name: Run tests diff --git a/.golangci.yml b/.golangci.yml index b72cc4d..999d9f0 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -13,30 +13,23 @@ linters-settings: gosec: excludes: - G103 + - G115 linters: enable-all: true disable: - - interfacer # deprecated - - scopelint # deprecated - - maligned # deprecated - - golint # deprecated - - exhaustivestruct # deprecated - - varcheck # deprecated - - nosnakecase # deprecated - - structcheck # deprecated - - deadcode # deprecated - - ifshort # deprecated + - execinquery # deprecated + - exportloopref # deprecated + - gomnd # deprecated - depguard + - err113 - exhaustive - exhaustruct - forcetypeassert - gochecknoglobals - - goerr113 - - gomnd - ireturn + - mnd - nlreturn - - maligned - varnamelen - wrapcheck - wsl diff --git a/go.mod b/go.mod index 3ca3835..d5aa2ed 100644 --- a/go.mod +++ b/go.mod @@ -1,12 +1,12 @@ module github.com/hamba/statter/v2 -go 1.21 +go 1.22 require ( github.com/VictoriaMetrics/metrics v1.35.1 github.com/cactus/go-statsd-client/v5 v5.1.0 github.com/hamba/logger/v2 v2.6.0 - github.com/prometheus/client_golang v1.20.3 + github.com/prometheus/client_golang v1.20.4 github.com/stretchr/testify v1.9.0 github.com/valyala/fastrand v1.1.0 ) diff --git a/go.sum b/go.sum index 3cdf2e2..6c399f6 100644 --- a/go.sum +++ b/go.sum @@ -28,8 +28,8 @@ github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/prometheus/client_golang v1.20.3 h1:oPksm4K8B+Vt35tUhw6GbSNSgVlVSBH0qELP/7u83l4= -github.com/prometheus/client_golang v1.20.3/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE= +github.com/prometheus/client_golang v1.20.4 h1:Tgh3Yr67PaOv/uTqloMsCEdeuFTatm5zIq5+qNN23vI= +github.com/prometheus/client_golang v1.20.4/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE= github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E= github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY= github.com/prometheus/common v0.55.0 h1:KEi6DK7lXW/m7Ig5i47x0vRzuBsHuvJdi5ee6Y3G1dc= diff --git a/internal/stats/stats.go b/internal/stats/stats.go index b115c0a..6d70cde 100644 --- a/internal/stats/stats.go +++ b/internal/stats/stats.go @@ -156,6 +156,7 @@ func (s *Sample) percentile(n float64) float64 { return s.perc[clamp(i, 0, len(s.perc)-1)] } +//nolint:predeclared func clamp(i float64, min, max int) int { if i < float64(min) { return min diff --git a/key.go b/key.go index 3998bdd..1b727d6 100644 --- a/key.go +++ b/key.go @@ -68,7 +68,7 @@ func sortTags(tags []Tag) { for !sorted { sorted = true lmo := len(tags) - 1 - for i := 0; i < lmo; i++ { + for i := range lmo { if tags[i+1][0] < tags[i][0] { tags[i+1], tags[i] = tags[i], tags[i+1] sorted = false diff --git a/reporter/statsd/statsd.go b/reporter/statsd/statsd.go index 471e484..4be2a3d 100644 --- a/reporter/statsd/statsd.go +++ b/reporter/statsd/statsd.go @@ -87,7 +87,7 @@ func (s *Statsd) Close() error { func toTags(t [][2]string) []statsd.Tag { res := make([]statsd.Tag, len(t)) - for i := 0; i < len(t); i++ { + for i := range t { res[i] = statsd.Tag{t[i][0], t[i][1]} } return res diff --git a/statter.go b/statter.go index 15243e3..90366b8 100644 --- a/statter.go +++ b/statter.go @@ -277,7 +277,7 @@ func (s *Statter) reportSample(name, suffix string, tags [][2]string, sample *st s.r.Gauge(prefix+"max"+suffix, sample.Max(), tags) ps := s.cfg.percentiles vs := sample.Percentiles(ps) - for i := 0; i < len(vs); i++ { + for i := range vs { name := prefix + strconv.FormatFloat(ps[i], 'g', -1, 64) + "p" + suffix s.r.Gauge(name, vs[i], tags) }