From 15743bc2d4498bd752de45185bd460d7de0edede Mon Sep 17 00:00:00 2001 From: Mark Sagi-Kazar Date: Thu, 9 Jan 2025 11:58:05 +0100 Subject: [PATCH] fix lint violations Signed-off-by: Mark Sagi-Kazar --- .golangci.yaml | 5 +++-- gcsfs/file.go | 5 ++--- gcsfs/gcs.go | 4 ++-- gcsfs/gcs_mocks.go | 3 ++- gcsfs/gcs_test.go | 2 +- iofs.go | 1 - iofs_test.go | 1 - memmap.go | 2 -- memmap_test.go | 4 ++-- sftpfs/sftp.go | 1 + 10 files changed, 13 insertions(+), 15 deletions(-) diff --git a/.golangci.yaml b/.golangci.yaml index ed6d4c9f..806289a2 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -3,13 +3,14 @@ linters-settings: sections: - standard - default - - prefix(github.com/spf13/viper) + - prefix(github.com/spf13/afero) linters: disable-all: true enable: + - gci - gofmt - # - gofumpt + - gofumpt - staticcheck issues: diff --git a/gcsfs/file.go b/gcsfs/file.go index 24019194..54178bc3 100644 --- a/gcsfs/file.go +++ b/gcsfs/file.go @@ -26,11 +26,10 @@ import ( "sort" "syscall" - "github.com/spf13/afero/gcsfs/internal/stiface" - "cloud.google.com/go/storage" - "google.golang.org/api/iterator" + + "github.com/spf13/afero/gcsfs/internal/stiface" ) // GcsFs is the Afero version adapted for GCS diff --git a/gcsfs/gcs.go b/gcsfs/gcs.go index b33bdeb1..f9daa21f 100644 --- a/gcsfs/gcs.go +++ b/gcsfs/gcs.go @@ -22,10 +22,10 @@ import ( "time" "cloud.google.com/go/storage" + "google.golang.org/api/option" + "github.com/spf13/afero" "github.com/spf13/afero/gcsfs/internal/stiface" - - "google.golang.org/api/option" ) type GcsFs struct { diff --git a/gcsfs/gcs_mocks.go b/gcsfs/gcs_mocks.go index 5d4e8372..9e64970a 100644 --- a/gcsfs/gcs_mocks.go +++ b/gcsfs/gcs_mocks.go @@ -18,9 +18,10 @@ import ( "strings" "cloud.google.com/go/storage" + "google.golang.org/api/iterator" + "github.com/spf13/afero" "github.com/spf13/afero/gcsfs/internal/stiface" - "google.golang.org/api/iterator" ) // sets filesystem separators to the one, expected (and hard-coded) in the tests diff --git a/gcsfs/gcs_test.go b/gcsfs/gcs_test.go index d1cf70da..ba3d09cd 100644 --- a/gcsfs/gcs_test.go +++ b/gcsfs/gcs_test.go @@ -17,9 +17,9 @@ import ( "syscall" "testing" + "cloud.google.com/go/storage" "golang.org/x/oauth2/google" - "cloud.google.com/go/storage" "github.com/spf13/afero" "github.com/spf13/afero/gcsfs/internal/stiface" ) diff --git a/iofs.go b/iofs.go index 938b9316..b13155ca 100644 --- a/iofs.go +++ b/iofs.go @@ -255,7 +255,6 @@ func (f fromIOFSFile) Readdir(count int) ([]os.FileInfo, error) { ret := make([]os.FileInfo, len(entries)) for i := range entries { ret[i], err = entries[i].Info() - if err != nil { return nil, err } diff --git a/iofs_test.go b/iofs_test.go index 829e9191..0f126f0d 100644 --- a/iofs_test.go +++ b/iofs_test.go @@ -146,7 +146,6 @@ func TestIOFSNativeDirEntryWhenPossible(t *testing.T) { return nil }) - if err != nil { t.Fatal(err) } diff --git a/memmap.go b/memmap.go index d6c744e8..ed92f564 100644 --- a/memmap.go +++ b/memmap.go @@ -16,11 +16,9 @@ package afero import ( "fmt" "io" - "log" "os" "path/filepath" - "sort" "strings" "sync" diff --git a/memmap_test.go b/memmap_test.go index c47fadc8..873cd904 100644 --- a/memmap_test.go +++ b/memmap_test.go @@ -881,7 +881,7 @@ func TestMemMapFsRename(t *testing.T) { } for _, dir := range data.dirs { - err = fs.MkdirAll(dir, os.FileMode(0775)) + err = fs.MkdirAll(dir, os.FileMode(0o775)) if err != nil { t.Fatalf("%s: MkdirAll %q failed: %v", fs.Name(), dir, err) } @@ -892,7 +892,7 @@ func TestMemMapFsRename(t *testing.T) { if err != nil { t.Fatalf("%s: rename %q, %q failed: %v", fs.Name(), data.from, data.to, err) } - err = fs.Mkdir(data.from, os.FileMode(0775)) + err = fs.Mkdir(data.from, os.FileMode(0o775)) if err != nil { t.Fatalf("%s: Mkdir %q failed: %v", fs.Name(), data.from, err) } diff --git a/sftpfs/sftp.go b/sftpfs/sftp.go index eadf1e07..534fbb19 100644 --- a/sftpfs/sftp.go +++ b/sftpfs/sftp.go @@ -18,6 +18,7 @@ import ( "time" "github.com/pkg/sftp" + "github.com/spf13/afero" )