Skip to content

Instantly share code, notes, and snippets.

@pboothe
Created March 26, 2025 12:24
Show Gist options
  • Save pboothe/7babfa2c89aaa00859c3dcf8f62bce8d to your computer and use it in GitHub Desktop.
Save pboothe/7babfa2c89aaa00859c3dcf8f62bce8d to your computer and use it in GitHub Desktop.
The golangci-lint configuration used for the Go code in Triple Pat as of 2025-03-26. Includes the reasoning behind each choice, and is set up for v2 of golangci-lint.
version: "2"
run:
issues-exit-code: 1
tests: true
output:
formats:
text:
path: stdout
print-linter-name: true
print-issued-lines: true
sort-order:
- severity
- file
- linter
linters:
default: all
disable:
- exhaustruct # HTTP servers (among others) are designed to be non-exhaustive.
- funlen # Long functions are not as bad as we used to think.
- gochecknoglobals # globals aren't evil. Love of globals is. Also, prometheus metrics are often globals.
- godox # Comments should be allowed to contain TODO or HACK or BUG.
- inamedparam # You shouldn't always need to name params in interfaces.
- ireturn # https://github.com/go-proverbs/go-proverbs.github.io/issues/37#issuecomment-571288298
- nlreturn # You don't need a blank line before every return.
- tagliatelle # Too many struct tags come from sources we don't control.
- testpackage # I support whitebox testing.
- varnamelen # db is a good name for a database, f for a function, etc..
- wrapcheck # You don't have to always wrap errors.
- wsl # I support a greater code density than this tool does.
settings:
depguard:
rules:
prevent_unmaintained_packages:
list-mode: strict # Be stricter.
files:
- $all # Look at every file.
allow: # Now you get a look behind the curtains!
- $gostd
- github.com/go-chi/chi/v5
- github.com/golang-jwt/jwt/v5
- github.com/google/uuid
- github.com/jackc/pgx/v5
- github.com/lestrrat-go/jwx/jwk
- github.com/m-lab/go/anonymize
- github.com/m-lab/go/flagx
- github.com/m-lab/go/httpx
- github.com/m-lab/go/prometheusx
- github.com/mattn/go-sqlite3
- github.com/pganalyze/pg_query_go/v6
- github.com/phires/go-guerrilla
- github.com/prometheus/
- github.com/samber/slog-chi
- github.com/samber/slog-logrus/v2
- github.com/sirupsen/logrus
- github.com/stretchr/testify
- github.com/triple-pat/
- golang.org/x/net/nettest
- google.golang.org/api/idtoken
errcheck:
disable-default-exclusions: true # Be stricter.
gocritic:
enable-all: true # Be stricter.
disabled-checks:
- unnamedResult # This enforces a style I do not like.
paralleltest:
ignore-missing: true # No need to put t.Parallel() everywhere.
promlinter:
strict: true # Be stricter.
revive:
rules:
# These are the most questionable config settings in this file.
# Right now we are in startup mode. The code is the API documentation for the code.
# In a non-startup situation, they should be configured the opposite way.
- name: exported # No need to have a doc comment on every exported f'n.
disabled: true
- name: package-comments # No need to have a doc comment for every package.
disabled: true
testifylint:
enable-all: true # Be stricter.
usetesting: # Be stricter.
context-background: true
context-todo: true
os-chdir: true
os-mkdir-temp: true
os-setenv: true
os-temp-dir: true
os-create-temp: true
formatters:
enable:
- gci
- gofmt
- gofumpt
- goimports
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment