From c2501d601b19c9f12e1ac0d9469ee5f5f4e693b5 Mon Sep 17 00:00:00 2001 From: Yad Smood <1415488+ysmood@users.noreply.github.com> Date: Fri, 1 Nov 2024 15:59:25 +0800 Subject: [PATCH] update linter --- .github/workflows/test.yml | 2 +- .golangci.yml | 21 +++++---------------- batch.go | 2 +- go.mod | 4 +--- lib/meta.go | 2 +- lib/secure/cipher.go | 2 +- 6 files changed, 10 insertions(+), 23 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c3f2394..8a2ac4c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -15,7 +15,7 @@ jobs: - uses: actions/checkout@v4 - name: lint - run: go run github.com/ysmood/golangci-lint@latest + run: go run github.com/ysmood/golangci-lint@v0.13.0 if: matrix.os == 'ubuntu-latest' - name: test diff --git a/.golangci.yml b/.golangci.yml index bd2c449..d59aeb6 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,6 +1,3 @@ -run: - skip-dirs-use-default: false - linters: enable-all: true disable: @@ -22,18 +19,12 @@ linters: - forcetypeassert - gci - depguard + - mnd - # Deprecated ones: - - structcheck - - interfacer - - deadcode - - varcheck - - ifshort - - exhaustivestruct - - golint - - maligned - - nosnakecase - - scopelint + - execinquery + - copyloopvar + - exportloopref + - copyloopvar linters-settings: gocyclo: @@ -44,8 +35,6 @@ linters-settings: lines: 100 issues: - exclude-use-default: false - exclude-rules: - path: main.go linters: diff --git a/batch.go b/batch.go index 5d9f367..495fde9 100644 --- a/batch.go +++ b/batch.go @@ -307,7 +307,7 @@ func (b *Batch) same(conf whisper.Config, inPath, outPath string) (bool, error) previousDigest, err := os.ReadFile(digestPath) if err != nil { - return false, nil //nolint: nilerr + return false, nil } return bytes.Equal(digest, previousDigest), nil diff --git a/go.mod b/go.mod index a4e0de4..2fc8742 100644 --- a/go.mod +++ b/go.mod @@ -1,8 +1,6 @@ module github.com/ysmood/whisper -go 1.21 - -toolchain go1.21.4 +go 1.22 require ( github.com/ysmood/byframe/v4 v4.0.0 diff --git a/lib/meta.go b/lib/meta.go index 63e1cb2..d85de2f 100644 --- a/lib/meta.go +++ b/lib/meta.go @@ -140,7 +140,7 @@ func DecodeMeta(in io.Reader) (*Meta, error) { // key num _, num := byframe.DecodeHeader(numRaw) - for i := 0; i < num; i++ { + for i := range num { key := make([]byte, meta.HashSize()) _, err = io.ReadFull(in, key) diff --git a/lib/secure/cipher.go b/lib/secure/cipher.go index 2fe504f..ff16a53 100644 --- a/lib/secure/cipher.go +++ b/lib/secure/cipher.go @@ -113,7 +113,7 @@ func (c *Cipher) Decoder(r io.Reader) (io.ReadCloser, error) { _, count := byframe.DecodeHeader(header) encryptedKeys := [][]byte{} - for i := 0; i < count; i++ { + for range count { encrypted, err := s.Next() if err != nil { return nil, err