Cette page est affichée en anglais. Une traduction française est en cours.
ConfigsMay 3, 2026·3 min de lecture

golangci-lint — Fast Go Linter Aggregator

A fast linters runner for Go that executes dozens of linters in parallel with shared analysis results, replacing the need to manage individual linter binaries.

Introduction

golangci-lint runs Go linters in parallel, sharing parsed AST and type information across linters so the aggregate run is faster than running each linter individually. It supports over 100 linters and is the standard choice for CI pipelines in Go projects.

What golangci-lint Does

  • Runs 100+ linters concurrently with shared type-checking results
  • Provides a single binary replacing dozens of individual linter installs
  • Supports per-project configuration via .golangci.yml
  • Outputs results in multiple formats: text, JSON, GitHub Actions, and Code Climate
  • Caches analysis results between runs for faster incremental checks

Architecture Overview

golangci-lint loads your Go packages once using go/analysis framework, then dispatches each enabled linter against the shared package data. Because type information and ASTs are computed once and shared, the total wall-clock time is much less than running linters sequentially. Results are deduplicated, severity-filtered, and formatted according to your output configuration.

Self-Hosting & Configuration

  • Install via the official install script or go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
  • Create .golangci.yml at your project root to configure enabled/disabled linters
  • Set severity levels and per-linter settings in the config file
  • Use --new-from-rev in CI to lint only changed code on pull requests
  • Integrate with GitHub Actions, GitLab CI, or any CI system via exit codes

Key Features

  • Executes linters 2-7x faster than running them individually due to shared analysis
  • Over 100 supported linters covering style, bugs, complexity, and security
  • Fine-grained issue exclusion by path, text, linter, or source line patterns
  • Auto-fix mode for linters that support automatic code correction
  • YAML configuration with inheritance and preset profiles

Comparison with Similar Tools

  • go vet — ships with Go but covers only a small set of checks; golangci-lint includes go vet plus many more
  • staticcheck — excellent standalone analyzer; golangci-lint bundles it alongside other linters in one run
  • revive — fast configurable linter; golangci-lint can run revive as one of its integrated linters
  • Reviewdog — report linter results on PRs; golangci-lint focuses on running linters, pairs well with Reviewdog
  • SonarQube — general-purpose code quality server; golangci-lint is Go-specific and runs locally or in CI

FAQ

Q: How do I enable only specific linters? A: In .golangci.yml, set linters.enable to a list of linter names. Use disable-all: true first.

Q: Can I lint only changed files in a PR? A: Yes. Use --new-from-rev=origin/main to report issues only in code modified since the base branch.

Q: Does it support custom linters? A: Yes. You can add custom linters via the plugin system or by writing go/analysis-based analyzers.

Q: How do I suppress false positives? A: Use //nolint:lintername comments on specific lines, or exclude patterns in the config file.

Sources

Fil de discussion

Connectez-vous pour rejoindre la discussion.
Aucun commentaire pour l'instant. Soyez le premier à partager votre avis.

Actifs similaires