From 67691df2df889769ae230a944e1c5f0e77a24b15 Mon Sep 17 00:00:00 2001
From: Chris Novakovic <chris@chrisn.me.uk>
Date: Mon, 19 Feb 2024 12:32:12 +0000
Subject: [PATCH] Replace linters with golangci-lint (#5)

---
 .github/workflows/testing.yml | 28 +++++++++++++---------------
 .golangci.yml                 |  8 ++++++++
 Makefile                      | 15 +--------------
 3 files changed, 22 insertions(+), 29 deletions(-)
 create mode 100644 .golangci.yml

diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml
index 3fef859f..21fd002e 100644
--- a/.github/workflows/testing.yml
+++ b/.github/workflows/testing.yml
@@ -7,35 +7,33 @@ on:
   pull_request:
   workflow_dispatch:
 
+permissions:
+  contents: read
+  pull-requests: read
+  checks: write
+
 jobs:
   test:
     name: Test and lint
     strategy:
       fail-fast: false
       matrix:
-        go: [ '1.18', '1.17' ]
+        go: [ '1.22', '1.21' ]
         os: [ 'windows-latest', 'ubuntu-latest', 'macOS-latest' ]
     runs-on: ${{ matrix.os }}
 
     steps:
-      - uses: actions/checkout@v3
-      - uses: actions/setup-go@v3
+      - uses: actions/checkout@v4
+
+      - uses: actions/setup-go@v5
         with:
           go-version: ${{ matrix.go }}
+          check-latest: true
 
-      - name: Run go fmt (Go ${{ matrix.go }})
-        if: runner.os != 'Windows'
-        run: diff -u <(echo -n) <(gofmt -d -s .)
-
-      - name: Run go vet
-        run: make vet
-
-      - name: Run staticcheck (Go ${{ matrix.go }})
-        uses: dominikh/staticcheck-action@v1.2.0
+      - name: Run golangci-lint (Go ${{ matrix.go }})
+        uses: golangci/golangci-lint-action@v4
         with:
-          version: "2022.1"
-          install-go: false
-          cache-key: ${{ matrix.go }}
+          version: v1.56
 
       - name: Run Unit tests (Go ${{ matrix.go }})
         run: make test
diff --git a/.golangci.yml b/.golangci.yml
new file mode 100644
index 00000000..fcffdeb7
--- /dev/null
+++ b/.golangci.yml
@@ -0,0 +1,8 @@
+run:
+  timeout: 5m
+
+issues:
+  exclude-rules:
+    - path: _test\.go
+      linters:
+        - errcheck
diff --git a/Makefile b/Makefile
index e9b063d7..981af6cb 100644
--- a/Makefile
+++ b/Makefile
@@ -8,18 +8,5 @@ help: ## Outputs the help.
 test: ## Runs all unit, integration and example tests.
 	go test -race -v ./...
 
-.PHONY: vet
-vet: ## Runs go vet (to detect suspicious constructs).
-	go vet ./...
-
-.PHONY: fmt
-fmt: ## Runs go fmt (to check for go coding guidelines).
-	gofmt -d -s .
-
-.PHONY: staticcheck
-staticcheck: ## Runs static analysis to prevend bugs, foster code simplicity, performance and editor integration.
-	go install honnef.co/go/tools/cmd/staticcheck@2022.1
-	staticcheck ./...
-
 .PHONY: all
-all: test vet fmt staticcheck ## Runs all source code quality targets (like test, vet, fmt, staticcheck)
+all: test