From 53785b6e6e0a7f69535da9028d3d5c1dd5d453c7 Mon Sep 17 00:00:00 2001 From: wispem-wantex Date: Sat, 23 Aug 2025 18:19:22 -0700 Subject: [PATCH] Add lint config and build step --- .gitea/workflows/CI.yaml | 5 ++- .golangci.yaml | 91 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 94 insertions(+), 2 deletions(-) create mode 100644 .golangci.yaml diff --git a/.gitea/workflows/CI.yaml b/.gitea/workflows/CI.yaml index 5550744..1fcb298 100644 --- a/.gitea/workflows/CI.yaml +++ b/.gitea/workflows/CI.yaml @@ -20,5 +20,6 @@ jobs: GOBIN=/usr/local/go/bin go install git.offline-twitter.com/offline-labs/gocheckout@v0.0.1 gocheckout - name: test - run: | - go test ./... + run: go test ./... + - name: lint + run: golangci-lint run diff --git a/.golangci.yaml b/.golangci.yaml new file mode 100644 index 0000000..34321d1 --- /dev/null +++ b/.golangci.yaml @@ -0,0 +1,91 @@ +version: "2" + +linters: + default: none + enable: + # Defaults + - errcheck + - govet + - ineffassign + - staticcheck + - unused + + # Extras + - depguard + - errorlint + - godox + - lll + - nolintlint + - sqlclosecheck + - whitespace + - wrapcheck + + settings: + depguard: + rules: + main: + deny: + - pkg: io/ioutil + desc: replace with the matching functions from `io` or `os` packages + - pkg: github.com/pkg/errors + desc: Should be replaced by standard lib errors package + errcheck: + # report about not checking of errors in type assertions: `a := b.(MyStruct)`; + # default is false: such cases aren't reported by default. + check-type-assertions: true + errorlint: + errorf: true # Ensure Errorf only uses %w (not %v or %s etc) for errors + asserts: true # Require errors.As instead of type-asserting + comparison: true # Require errors.Is instead of equality-checking + godox: + # report any comments starting with keywords, this is useful for TODO or FIXME comments that + # might be left in the code accidentally and should be resolved before merging + keywords: # default keywords are TODO, BUG, and FIXME, these can be overwritten by this setting + - XXX + govet: + enable-all: true + disable: + - fieldalignment + lll: + line-length: 140 + tab-width: 4 + nolintlint: + require-explanation: true + require-specific: true + allow-unused: false + staticcheck: + go: "1.24" + checks: + - all + - -ST1000 # Re-enable this once we have docstrings + - -ST1001 # Dot imports are good sometimes (e.g., in test packages) + - -ST1003 # I like snake_case + - -ST1013 # HTTP status codes are shorter and more readable than names + exclusions: + generated: lax # Don't lint generated files + paths: + +formatters: + enable: + - gci + - gofmt + settings: + gci: + sections: + - standard + - default + - localmodule + gofmt: + simplify: true + exclusions: + generated: lax + paths: + +run: + build-tags: + - integration + +issues: + max-same-issues: 0 + max-issues-per-linter: 0 + uniq-by-line: false