From d1e304760f6688e25f187d4fa00f796375c7cdc1 Mon Sep 17 00:00:00 2001
From: jkito <belter@riseup.net>
Date: Tue, 18 Jun 2024 01:55:41 +0530
Subject: [PATCH] chore: add golangci-lint config and make target to run linter

---
 .golangci.yaml | 21 +++++++++++++++++++++
 Makefile       |  6 +++++-
 2 files changed, 26 insertions(+), 1 deletion(-)
 create mode 100644 .golangci.yaml

diff --git a/.golangci.yaml b/.golangci.yaml
new file mode 100644
index 00000000..fbce50d6
--- /dev/null
+++ b/.golangci.yaml
@@ -0,0 +1,21 @@
+issues:
+  exclude-use-default: true
+  exclude-dirs-use-default: true
+  exclude-files:
+    - ".*\\.cpp$"
+    - ".*\\.h$"
+    - ".*\\.sh$"
+    - ".*\\.py$"
+    - ".*\\.qml$"
+  exclude-dirs:
+    - "gui"
+linters:
+  disable-all: true
+  enable:
+    - errcheck
+    - gosimple
+    - ineffassign
+    - govet
+    - unused
+    - gofmt
+
diff --git a/Makefile b/Makefile
index e5792037..107b418d 100644
--- a/Makefile
+++ b/Makefile
@@ -26,7 +26,7 @@ OSXMORDORUID ?= uid
 GOPATH = $(shell go env GOPATH)
 TARGET_GOLIB=lib/libgoshim.a
 SOURCE_GOLIB=gui/backend.go
-SOURCE_DIRS_GO = pkg cmd tests gui
+SOURCE_DIRS_GO = pkg cmd gui
 
 # detect OS
 UNAME = $(shell uname -s)
@@ -312,6 +312,10 @@ test:
 fmt:
 	@gofmt -s -w $(SOURCE_DIRS_GO)
 
+.PHONY: lint
+lint:
+	golangci-lint run  --timeout=5m
+
 test_ui: build_golib
 	@${QMAKE} -o tests/Makefile test.pro
 	@${MAKE} -C tests clean
-- 
GitLab