From e3dd6360ff6577c71327bb69b911fd3e2df330ba Mon Sep 17 00:00:00 2001 From: Pulok Saha Date: Tue, 9 Dec 2025 14:41:14 +0600 Subject: [PATCH] Use golangci-lint 2.x Signed-off-by: Pulok Saha --- .golangci.yml | 28 ++++++++++++++++++++++++++++ Makefile | 2 +- go.mod | 4 +--- lintconf.yaml | 43 ------------------------------------------- pkg/backup.go | 2 +- pkg/restore.go | 4 ++-- pkg/util.go | 2 +- 7 files changed, 34 insertions(+), 51 deletions(-) create mode 100644 .golangci.yml delete mode 100644 lintconf.yaml diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 00000000..cdd2defc --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,28 @@ +version: "2" +linters: + default: standard + enable: + - unparam + +formatters: + enable: + - gofmt + - goimports + settings: + gofmt: + rewrite-rules: + - pattern: 'interface{}' + replacement: 'any' + +issues: + max-same-issues: 100 + + exclude-files: + - generated.*\\.go + + exclude-dirs: + - client + - vendor + +run: + timeout: 10m diff --git a/Makefile b/Makefile index 5e89fc4f..9d598cfa 100644 --- a/Makefile +++ b/Makefile @@ -282,7 +282,7 @@ lint: $(BUILD_DIRS) --env GO111MODULE=on \ --env GOFLAGS="-mod=vendor" \ $(BUILD_IMAGE) \ - golangci-lint run --enable $(ADDTL_LINTERS) --timeout=30m --exclude-files="generated.*\.go$\" --exclude-dirs-use-default --exclude-dirs=client,vendor + golangci-lint run $(BUILD_DIRS): @mkdir -p $@ diff --git a/go.mod b/go.mod index 825b05b1..67e90fa2 100644 --- a/go.mod +++ b/go.mod @@ -1,8 +1,6 @@ module stash.appscode.dev/nats -go 1.23.0 - -toolchain go1.24.4 +go 1.25.5 require ( github.com/spf13/cobra v1.8.0 diff --git a/lintconf.yaml b/lintconf.yaml deleted file mode 100644 index 860d7cb9..00000000 --- a/lintconf.yaml +++ /dev/null @@ -1,43 +0,0 @@ -# adapted from: https://github.com/helm/chart-testing/raw/master/etc/lintconf.yaml ---- -rules: - braces: - min-spaces-inside: 0 - max-spaces-inside: 0 - min-spaces-inside-empty: -1 - max-spaces-inside-empty: -1 - brackets: - min-spaces-inside: 0 - max-spaces-inside: 0 - min-spaces-inside-empty: -1 - max-spaces-inside-empty: -1 - colons: - max-spaces-before: 0 - max-spaces-after: 1 - commas: - max-spaces-before: 0 - min-spaces-after: 1 - max-spaces-after: 1 - comments: - require-starting-space: true - min-spaces-from-content: 1 - document-end: disable - document-start: disable # No --- to start a file - empty-lines: - max: 2 - max-start: 0 - max-end: 0 - hyphens: - max-spaces-after: 1 - indentation: - spaces: consistent - indent-sequences: whatever # - list indentation will handle both indentation and without - check-multi-line-strings: false - key-duplicates: enable - line-length: disable # Lines can be any length - new-line-at-end-of-file: enable - new-lines: - type: unix - trailing-spaces: enable - truthy: - level: warning diff --git a/pkg/backup.go b/pkg/backup.go index ff922a38..ef0f9a94 100644 --- a/pkg/backup.go +++ b/pkg/backup.go @@ -305,7 +305,7 @@ func (opt *natsOptions) writeStreamNamesToFile(sh *shell.Session) error { } func (opt *natsOptions) writeAll(sh *shell.Session) error { - args := []interface{}{ + args := []any{ "stream", "ls", "--json", diff --git a/pkg/restore.go b/pkg/restore.go index f6f54535..ead8a983 100644 --- a/pkg/restore.go +++ b/pkg/restore.go @@ -244,7 +244,7 @@ func (opt *natsOptions) restoreNATS(targetRef api_v1beta1.TargetRef) (*restic.Re } func removeMatchedStreams(sh *shell.Session, streams []string) error { - lsArgs := []interface{}{ + lsArgs := []any{ "stream", "ls", "--json", @@ -257,7 +257,7 @@ func removeMatchedStreams(sh *shell.Session, streams []string) error { if err := json.Unmarshal(byteStreams, &currStreams); err != nil { return err } - rmArgs := []interface{}{ + rmArgs := []any{ "stream", "rm", "-f", diff --git a/pkg/util.go b/pkg/util.go index b7f0bbab..4d1da433 100644 --- a/pkg/util.go +++ b/pkg/util.go @@ -201,7 +201,7 @@ func clearDir(dir string) error { func (session sessionWrapper) waitForNATSReady(warningThreshold string) error { klog.Infoln("Waiting for the nats server to be ready...") - args := []interface{}{ + args := []any{ "server", "check", "connection",