How to Use golangci-lint for Comprehensive Linting

Configure and run golangci-lint with a .golangci.yml file to enforce code quality standards like govet and gofumpt across your Go project.

Run golangci-lint run with a .golangci.yml configuration file to enforce specific linters and formatters across your codebase. Create a .golangci.yml file in your project root to define enabled linters like govet and ineffassign, and formatters like gofmt and gofumpt with specific settings.

version: "2"
linters:
  default: none
  enable:
    - govet
    - ineffassign
formatters:
  enable:
    - gofmt
    - gofumpt
  settings:
    gofmt:
      simplify: true
    gofumpt:
      module-path: github.com/jackc/pgx/v5
      extra-rules: true

Execute the linter against your code using the command golangci-lint run ./... to check all packages.