pgx icon indicating copy to clipboard operation
pgx copied to clipboard

🔧 Integrate golangci-lint for Static Code Analysis

Open Saurabh2402 opened this issue 1 year ago • 0 comments

Is your feature request related to a problem? Please describe.

  • To improve code quality and maintain consistency across the project, I'd like to propose adding golangci-lint to our development workflow.
  • Relying solely on code reviews for style and bug detection, which is less efficient and more error-prone than automated linting.

Describe the solution you'd like

  • This tool helps catch common bugs, enforces style guidelines, and ensures adherence to Go best practices—all with minimal setup and configuration.

Describe alternatives you've considered

  • Using go vet and gofmt separately for static analysis and formatting, though they cover fewer checks and require more manual setup.
  • Employing other linters like staticcheck or revive, but these are less comprehensive or require combining multiple tools.

Additional context Why this matters:

  • Identifies potential bugs early through static analysis
  • Maintains consistent code style and formatting
  • Reduces technical debt over time
  • Speeds up code reviews with automated checks

Proposed steps

  1. Add a formatter section in the [.golangci.yml] linter file and format the entire codebase. This will rearrange imports and remove unnecessary whitespaces.

  2. Introduce only the staticcheck linter and lint the codebase to catch common bugs and issues.

  3. Add govet and gocritic linters, then lint the codebase again to catch more subtle issues.

  4. Ensure linting runs automatically on pull requests by integrating it into the CI/CD pipeline.

  5. Gradually add more useful linters as needed and lint the codebase accordingly.

I would like to take ownership of implementing this proposal. Please let me know if there are any specific requirements or preferences before I begin.

Saurabh2402 avatar Aug 13 '25 15:08 Saurabh2402