Back to articles
Golangci-lint: Your Go Guardian Against Code Smells
How-ToTools

Golangci-lint: Your Go Guardian Against Code Smells

via Dev.toRussell Jones

Ahnii! This post covers what golangci-lint does, how to configure it for a real project, and the linters worth enabling beyond the defaults. Why Not Just go vet ? go vet catches a narrow set of issues — wrong printf format strings, unreachable code, bad struct tags. It is a baseline, not a linter suite. golangci-lint runs dozens of linters in a single pass and reports unified output. It is fast because it reuses the Go build cache and runs linters concurrently. Install It # Homebrew brew install golangci-lint # Go install (pinned version) go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest Verify with golangci-lint --version . The v2 config format ( version: "2" ) is current. A Starter Configuration Create .golangci.yml at your project root. Start with default: standard and add linters that catch real problems: version : " 2" linters : default : standard enable : - bodyclose # unclosed HTTP response bodies - contextcheck # context.Context misuse - errname # error type

Continue reading on Dev.to

Opens in a new tab

Read Full Article
5 views

Related Articles