From 90920777f01144827c7f17c9801305377ed572bd Mon Sep 17 00:00:00 2001 From: Karming <41309630+karmingc@users.noreply.github.com> Date: Mon, 24 Jul 2023 18:50:49 -0400 Subject: [PATCH] feat: add some custom linters to golangci-lint (#3) Automate a lot of recurring errors. --- .golangci.yml | 17 +++++++++++++++++ Makefile | 4 ++++ ...ts--add-custom-linters-to-golangci-lint.yaml | 4 ++++ main.go | 5 ++++- 4 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 .golangci.yml create mode 100644 changelog/pending/20230724--feat-developer-experience-tests--add-custom-linters-to-golangci-lint.yaml diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 0000000..bb78ccd --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,17 @@ +linters: + enable: + - errname + - errorlint + - exhaustive + - exhaustruct + - gocheckcompilerdirectives + - gochecknoglobals + - goconst + - goerr113 + - gosec + - godot + - misspell + - stylecheck + - tagliatelle + - unparam + - revive diff --git a/Makefile b/Makefile index 0c8965e..7d3881e 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,7 @@ +.PHONE: lint +lint: ## Lint the code with golangci-lint + docker run --rm -v $$(pwd):/app -w /app golangci/golangci-lint golangci-lint run -v + .PHONY: changelog changelog: ## Generates a changelog with the template under ./changelog/config.yaml. go run github.com/aaronfriel/go-change@v0.1.2 create diff --git a/changelog/pending/20230724--feat-developer-experience-tests--add-custom-linters-to-golangci-lint.yaml b/changelog/pending/20230724--feat-developer-experience-tests--add-custom-linters-to-golangci-lint.yaml new file mode 100644 index 0000000..a5277de --- /dev/null +++ b/changelog/pending/20230724--feat-developer-experience-tests--add-custom-linters-to-golangci-lint.yaml @@ -0,0 +1,4 @@ +changes: +- type: patch + scope: feat/developer experience,tests + description: Add custom linters to golangci-lint diff --git a/main.go b/main.go index b891277..956ad6f 100644 --- a/main.go +++ b/main.go @@ -1,7 +1,10 @@ package main -import "fmt" +import ( + "fmt" +) func main() { fmt.Println("Hello, welcome to go-template!") + }