From 876cdb7c54a11c6b578303df68f98ce09e48af2f Mon Sep 17 00:00:00 2001 From: Bobby Donchev Date: Sat, 24 May 2025 13:18:05 +0400 Subject: [PATCH] feat: update go --- .github/workflows/main.yml | 6 +- .github/workflows/release.yml | 9 +- .golangci.yml | 239 ++++++++++++++++++++++++---------- Makefile | 2 + go.mod | 2 +- go.sum | 6 + 6 files changed, 188 insertions(+), 76 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 61a4fde..1f72930 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -10,10 +10,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - name: Setup Go - uses: actions/setup-go@v2 + - uses: actions/setup-go@v5 with: - go-version: 1.18 + go-version-file: "go.mod" + cache-dependency-path: "go.sum" - name: Run build binary run: make build - name: Setup make diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a3b3791..8548620 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -13,17 +13,18 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: fetch-depth: 0 - name: Fetch all tags run: git fetch --force --tags - name: Set up Go - uses: actions/setup-go@v2 + uses: actions/setup-go@v5 with: - go-version: 1.18 + go-version-file: "go.mod" + cache-dependency-path: "go.sum" - name: Run GoReleaser - uses: goreleaser/goreleaser-action@v2 + uses: goreleaser/goreleaser-action@v6 with: distribution: goreleaser version: latest diff --git a/.golangci.yml b/.golangci.yml index fe4511a..2b641b2 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,94 +1,197 @@ +version: "2" run: - concurrency: 4 - timeout: 5m - issues-exit-code: 1 - tests: true - modules-download-mode: readonly - allow-parallel-runners: true - -output: - # colored-line-number|line-number|json|tab|checkstyle|code-climate, default is "colored-line-number" - format: colored-line-number - print-issued-lines: false - sort-results: true - + tests: false linters: - disable-all: true + default: none enable: + - asasalint + - asciicheck + - bidichk - bodyclose - - deadcode - - depguard + - canonicalheader + - contextcheck + - copyloopvar + - cyclop + - decorder - dogsled - - dupl - - lll + - dupword + - durationcheck + - err113 - errcheck + - errname + - errorlint - exhaustive + - fatcontext + - forbidigo - funlen + - ginkgolinter + - gocheckcompilerdirectives + - gochecknoglobals - gochecknoinits + - gochecksumtype + - gocognit - goconst + - gocritic - gocyclo - - gofmt - - goimports - - revive - - gomnd + - godot + - goheader + - gomoddirectives + - gomodguard - goprintffuncname - gosec - - gosimple + - gosmopolitan - govet + - grouper + - importas + - inamedparam - ineffassign + - interfacebloat + - intrange + - loggercheck + - maintidx + - makezero + - mirror - misspell + - mnd + - musttag - nakedret + - nestif + - nilerr + - nilnil - noctx - nolintlint + - nosprintfhostport + - perfsprint + - predeclared + - promlinter + - protogetter + - reassign + - revive - rowserrcheck - - prealloc - - exportloopref + - sloglint + - spancheck + - sqlclosecheck - staticcheck - - structcheck - - stylecheck - - typecheck + - tagliatelle + - testableexamples + - testifylint + - thelper + - tparallel - unconvert - unparam - unused - - varcheck - - nlreturn + - usestdlibvars + - usetesting + - wastedassign - whitespace - - gocritic - - exportloopref - - gocognit + - wrapcheck + - zerologlint + settings: + cyclop: + max-complexity: 30 + package-average: 10 + errcheck: + check-type-assertions: true + funlen: + lines: 100 + ignore-comments: true + gocritic: + settings: + captLocal: + paramsOnly: false + underef: + skipRecvDeref: false + godot: + capital: true + gosec: + config: + G101: + pattern: (?i)passwd|pass|password|pwd|secret|token|pw|apiKey|bearer|credential + global: + "#nosec": gosec-ignore + govet: + disable: + - fieldalignment + enable-all: true + inamedparam: + skip-single-param: true + mnd: + ignored-functions: + - args.Error + - flag.Arg + - flag.Duration.* + - flag.Float.* + - flag.Int.* + - flag.Uint.* + - os.Chmod + - os.Mkdir.* + - os.OpenFile + - os.WriteFile + - prometheus.ExponentialBuckets.* + - prometheus.LinearBuckets + nlreturn: + block-size: 3 + nolintlint: + require-specific: true + perfsprint: + strconcat: false + revive: + rules: + - name: unused-parameter + disabled: true + rowserrcheck: + packages: + - github.com/jmoiron/sqlx + tagliatelle: + case: + rules: + json: snake + testpackage: + skip-regexp: _internal_test\.go + varnamelen: + max-distance: 6 + exclusions: + generated: lax + presets: + - comments + - common-false-positives + - legacy + - std-error-handling + rules: + - linters: + - unparam + text: result \d+ \([^)]+\) is always + paths: + - \.pb\.go$ + - \.connect\.go$ + - \.sql\.go$ + - _templ\.go$ + - migrate\.go + - ^.git + - ^api + - ^proto + - ^test + - third_party$ + - builtin$ + - examples$ +formatters: + enable: + - gci + - gofmt - gofumpt - - godot - - fast: false - -issues: - max-same-issues: 50 - max-issues-per-linter: 100 - -linters-settings: - funlen: - lines: 120 - # stmtLimit: 100 - lll: - line-length: 160 - gomnd: - settings: - mnd: - checks: argument,case,condition,return - errcheck: - check-type-assertions: true - check-blank: true - gocognit: - # minimal code complexity to report, 30 by default (but we recommend 10-20) - min-complexity: 15 - gocyclo: - # minimal code complexity to report, 30 by default (but we recommend 10-20) - min-complexity: 10 - godot: - # comments to be checked: `declarations`, `toplevel`, or `all` - scope: declarations - # check that each sentence starts with a capital letter - capital: true - govet: - # report about shadowed variables - check-shadowing: true + - goimports + exclusions: + generated: lax + paths: + - \.pb\.go$ + - \.connect\.go$ + - \.sql\.go$ + - _templ\.go$ + - migrate\.go + - ^.git + - ^api + - ^proto + - ^test + - third_party$ + - builtin$ + - examples$ diff --git a/Makefile b/Makefile index 333f532..cf32ec8 100644 --- a/Makefile +++ b/Makefile @@ -32,6 +32,8 @@ run: fresh fresh: clean build +deps: + go mod tidy -v test: go test -race -count=1 -v --coverprofile=coverage.txt ./... diff --git a/go.mod b/go.mod index bb89e33..da2b143 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/neurocode-io/cache-offloader -go 1.18 +go 1.24.2 require ( github.com/go-redis/redis/v8 v8.11.5 diff --git a/go.sum b/go.sum index 6761d89..422e051 100644 --- a/go.sum +++ b/go.sum @@ -62,6 +62,7 @@ github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.m github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4= +github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= @@ -120,6 +121,7 @@ github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg= +github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= @@ -168,8 +170,11 @@ github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjY github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= +github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE= +github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU= github.com/onsi/gomega v1.18.1 h1:M1GfJqGRrBrrGGsbxzV5dqM2U2ApXefZCQpkukxYRLE= +github.com/onsi/gomega v1.18.1/go.mod h1:0q+aL8jAiMXy9hbwj2mr5GziHiwhAIQpFmmtT5hitRs= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= @@ -499,6 +504,7 @@ gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogR gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= +gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=