From ff39bb40e65869de272187542acd24241d4fb872 Mon Sep 17 00:00:00 2001 From: Martin Tournoij Date: Sat, 30 Jul 2022 12:53:47 +0200 Subject: [PATCH] Fix lint (#476) Didn't run for some reasons; something with the actions cache: /usr/bin/tar --use-compress-program zstd -d -xf /home/runner/work/_temp/b9a1abd7-273e-449f-b255-5e8e947b3f97/cache.tzst -P -C /home/runner/work/fsnotify/fsnotify Error: /usr/bin/tar: ../../../go/pkg/mod/golang.org/x/sys@v0.0.0-20220412211240-33da011f77ad/windows/race0.go: Cannot open: File exists Error: /usr/bin/tar: ../../../go/pkg/mod/golang.org/x/sys@v0.0.0-20220412211240-33da011f77ad/windows/types_windows.go: Cannot open: File exists Replace it with staticcheck; which is nicer anyway. --- .github/workflows/build.yml | 12 ++++-------- .github/workflows/lint.yml | 30 ------------------------------ .github/workflows/staticcheck.yml | 13 +++++++++++++ .github/workflows/test.yml | 6 ++---- .github/workflows/vagrant.yml | 6 ++---- inotify_test.go | 6 +++--- 6 files changed, 24 insertions(+), 49 deletions(-) delete mode 100644 .github/workflows/lint.yml create mode 100644 .github/workflows/staticcheck.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0d004c1c..59ef7dc2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,15 +1,11 @@ -name: build -on: - push: - pull_request: +name: 'build' +on: ['push', 'pull_request'] jobs: - cross-compile-supported: + cross-compile: strategy: fail-fast: false matrix: - go: - - '1.16' - - '1.18' + go: ['1.16', '1.18'] runs-on: ubuntu-latest steps: - name: setup Go diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml deleted file mode 100644 index 5df65274..00000000 --- a/.github/workflows/lint.yml +++ /dev/null @@ -1,30 +0,0 @@ -name: test -on: - push: - pull_request: -jobs: - lint: - runs-on: ubuntu-latest - steps: - - name: setup Go - uses: actions/setup-go@v3 - with: - go-version: '1.18' - - - name: checkout - uses: actions/checkout@v3 - - - name: gofmt - run: | - test -z "$(gofmt -s -d . | tee /dev/stderr)" - - - name: vet - run: | - go vet ./... - - - name: golangci-lint - uses: golangci/golangci-lint-action@v3 - continue-on-error: true - with: - version: latest - skip-go-installation: true diff --git a/.github/workflows/staticcheck.yml b/.github/workflows/staticcheck.yml new file mode 100644 index 00000000..22e222ae --- /dev/null +++ b/.github/workflows/staticcheck.yml @@ -0,0 +1,13 @@ +name: 'staticcheck' +on: ['push', 'pull_request'] +jobs: + staticcheck: + name: 'staticcheck' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 1 + - uses: dominikh/staticcheck-action@v1.2.0 + with: + version: '2022.1' diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d6fa9661..5cd355ad 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,7 +1,5 @@ -name: test -on: - push: - pull_request: +name: 'test' +on: ['push', 'pull_request'] jobs: test: strategy: diff --git a/.github/workflows/vagrant.yml b/.github/workflows/vagrant.yml index 1cb822f8..76bce8a0 100644 --- a/.github/workflows/vagrant.yml +++ b/.github/workflows/vagrant.yml @@ -1,7 +1,5 @@ -name: vagrant -on: - push: - pull_request: +name: 'test' +on: ['push', 'pull_request'] jobs: test: strategy: diff --git a/inotify_test.go b/inotify_test.go index d9ee53ff..9aed1bec 100644 --- a/inotify_test.go +++ b/inotify_test.go @@ -132,7 +132,7 @@ func TestInotifyCloseCreate(t *testing.T) { } h.Close() select { - case _ = <-w.Events: + case <-w.Events: case err := <-w.Errors: t.Fatalf("Error from watcher: %v", err) case <-time.After(50 * time.Millisecond): @@ -144,7 +144,7 @@ func TestInotifyCloseCreate(t *testing.T) { // Now we try to swap the file descriptor under its nose. w.Close() w, err = NewWatcher() - defer w.Close() + defer func() { _ = w.Close() }() if err != nil { t.Fatalf("Failed to create second watcher: %v", err) } @@ -351,7 +351,7 @@ func TestInotifyInnerMapLength(t *testing.T) { if err != nil { t.Fatalf("Failed to remove testFile: %v", err) } - _ = <-w.Events // consume Remove event + <-w.Events // consume Remove event <-time.After(50 * time.Millisecond) // wait IN_IGNORE propagated func() {