Skip to content

Modern Docker Management, Designed for Everyone

ci/cd: add go linter

Kyle Mendell1b04d74c67be
diff --git a/.github/workflows/go-linter.yml b/.github/workflows/go-linter.yml
new file mode 100644
index 000000000..0b6a2eadc
--- /dev/null
+++ b/.github/workflows/go-linter.yml
@@ -0,0 +1,36 @@
+name: Run Backend Linter
+
+on:
+ push:
+ branches: [main]
+ paths:
+ - 'backend/**'
+ pull_request:
+ branches: [main]
+ paths:
+ - 'backend/**'
+
+permissions:
+ contents: read
+ pull-requests: read
+ checks: write
+
+jobs:
+ golangci-lint:
+ name: Run Golangci-lint
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout code
+ uses: actions/checkout@v4
+
+ - name: Set up Go
+ uses: actions/setup-go@v5
+ with:
+ go-version-file: backend/go.mod
+
+ - name: Run Golangci-lint
+ uses: golangci/golangci-lint-action@dec74fa03096ff515422f71d18d41307cacde373
+ with:
+ version: v2.0.2
+ working-directory: backend
+ only-new-issues: ${{ github.event_name == 'pull_request' }}
diff --git a/backend/.golangci.yml b/backend/.golangci.yml
new file mode 100644
index 000000000..37dd3b863
--- /dev/null
+++ b/backend/.golangci.yml
@@ -0,0 +1,63 @@
+version: '2'
+run:
+ tests: true
+ timeout: 5m
+linters:
+ default: none
+ enable:
+ - asasalint
+ - asciicheck
+ - bidichk
+ - bodyclose
+ - contextcheck
+ - copyloopvar
+ - durationcheck
+ - errcheck
+ - errchkjson
+ - errorlint
+ - exhaustive
+ - gocheckcompilerdirectives
+ - gochecksumtype
+ - gocognit
+ - gocritic
+ - gosec
+ - gosmopolitan
+ - govet
+ - ineffassign
+ - loggercheck
+ - makezero
+ - musttag
+ - nilerr
+ - nilnesserr
+ - noctx
+ - protogetter
+ - reassign
+ - recvcheck
+ - rowserrcheck
+ - spancheck
+ - sqlclosecheck
+ - staticcheck
+ - testifylint
+ - unused
+ - usestdlibvars
+ - zerologlint
+ exclusions:
+ generated: lax
+ presets:
+ - comments
+ - common-false-positives
+ - legacy
+ - std-error-handling
+ paths:
+ - third_party$
+ - builtin$
+ - examples$
+formatters:
+ enable:
+ - goimports
+ exclusions:
+ generated: lax
+ paths:
+ - third_party$
+ - builtin$
+ - examples$