Configuration golangci-lint pour Go

VérifiéSûr

Initialise ou met à jour la configuration golangci-lint pour les projets Go avec un ensemble complet de linters. Elle propose une configuration pragmatique équilibrant la qualité du code et la vitesse de développement, prête pour l'intégration CI/CD. Aide les équipes à appliquer des standards de code cohérents et à détecter les bogues tôt.

Spar Skills Guide Bot
DeveloppementDébutant
02/06/2026
Claude Code
#golang#linting#code-quality#static-analysis

Recommandé pour

Synthèse automatique

Configure golangci-lint pour un projet Go avec une configuration équilibrée entre rigueur et pragmatisme.

Points forts

  • Exécution parallèle des linters avec cache, jusqu'à 5 fois plus rapide
  • 90+ linters couvrant bugs, performances, style et sécurité
  • Configuration YAML hautement personnalisable
  • Intégration CI/CD prête (GitHub Actions, GitLab CI, pre-commit)

Limites

  • Nécessite que golangci-lint soit installé (v2.4.0+)
  • La configuration par défaut peut être trop stricte pour certains projets
  • Ne remplace pas une revue manuelle approfondie
Quand l'utiliser

Quand vous voulez appliquer des standards de qualité de code Go de manière automatisée et cohérente.

Quand l'éviter

Si votre projet utilise déjà un outil de linting adapté ou si la flexibilité est plus importante que la rigueur.

Analyse de sécurité

Sûr
Score qualité85/100

The skill provides instructions for copying a configuration file, running golangci-lint, and integrating with CI/CD. No destructive or obfuscated commands, no data exfiltration, no suppression of security features. All operations are standard development setup.

Aucun point d'attention détecté

Comment cette analyse est faite

Exemples

Initialize golangci-lint for a Go project
Set up golangci-lint in my Go project with a sensible default configuration and CI integration.
Update existing golangci-lint config
Update my .golangci.yml to use the latest best practices and enable all useful linters.

name: golangci-lint description: Initialize or update golangci-lint configuration for Go projects with comprehensive code quality checks, static analysis, and best practices enforcement

golangci-lint Setup Skill

Configure professional-grade linting for Go projects with sensible defaults that balance code quality with pragmatic development.

Overview

golangci-lint is a fast, parallel linter aggregator for Go that runs 90+ linters simultaneously. It's the industry standard for Go code quality enforcement.

Benefits:

  • Speed: Runs linters in parallel with caching (5x faster than individual linters)
  • Comprehensive: 90+ linters covering code quality, bugs, performance, and style
  • Configurable: Highly customizable via YAML configuration
  • CI/CD Ready: Seamless integration with GitHub Actions, GitLab CI, and pre-commit hooks
  • Editor Integration: Works with VS Code, GoLand, Vim, and Emacs

This skill provides a battle-tested configuration (in assets/.golangci.yml) optimized for golangci-lint v2.4.0+ that enables all linters by default while disabling overly strict or opinionated ones.

Prerequisites

  1. Go installed: Go 1.21+ recommended (go version)
  2. golangci-lint installed: Version 2.4.0+
    • macOS: brew install golangci-lint
    • Other: go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
    • Verify: golangci-lint --version
  3. Go module: Project uses Go modules (go.mod exists)

Instructions

Step 1: Verify Project Setup

# Verify Go module
ls go.mod

# Check for existing config
ls -la .golangci.yml .golangci.yaml

# Verify installation (should be version >=2)
golangci-lint --version

Step 2: Copy Configuration File

Copy the base configuration from assets:

# Copy template to project root
cp assets/.golangci.yml .golangci.yml

The asset configuration follows these principles:

  • Enable all by default: Maximum coverage with default: all
  • Disable the noisy: Removes linters that are too opinionated or project-specific
  • Pragmatic over perfect: Balances quality with development velocity
  • Project-agnostic: Works for most Go projects out of the box

Step 3: Run Initial Lint Check

Test the configuration:

# Run linter on entire project
golangci-lint run ./...

# Verbose output to see active linters
golangci-lint run -v ./...

# Test specific linter
golangci-lint run --disable-all --enable=govet ./...

Step 6: Integrate with CI/CD

GitHub Actions

Already configured if using the github-workflows skill. Otherwise:

- name: golangci-lint
  uses: golangci/golangci-lint-action@v6
  with:
    version: v2.4.0
    args: --timeout=5m

GitLab CI

lint:
  stage: test
  image: golangci/golangci-lint:v2.4.0
  script:
    - golangci-lint run -v ./...
  rules:
    - if: $CI_PIPELINE_SOURCE == "merge_request_event"
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH

Taskfile Integration

version: '3'

tasks:
  lint:
    desc: Run golangci-lint
    cmds:
      - golangci-lint run --timeout=5m ./...

  lint:fix:
    desc: Run with auto-fix
    cmds:
      - golangci-lint run --fix --timeout=5m ./...

Pre-commit Hook

# .pre-commit-config.yaml
repos:
  - repo: https://github.com/golangci/golangci-lint
    rev: v2.4.0
    hooks:
      - id: golangci-lint
        args: [--timeout=5m]

Step 7: Document in README

Add to your project's README.md:

## Code Quality

This project uses [golangci-lint](https://golangci-lint.run) for code quality enforcement.

**⚠️ All linting issues MUST be fixed before pushing commits.**

### Running the Linter

```bash
# Check for issues
golangci-lint run ./...

# Auto-fix where possible
golangci-lint run --fix ./...

Pre-commit Checklist

  1. ✅ Run golangci-lint run ./...
  2. ✅ Fix all reported issues
  3. ✅ Ensure tests pass: go test ./...
  4. ✅ Commit and push

CI automatically checks all PRs. PRs with linting errors will be blocked.


### Step 8: Configure Editor Integration

#### VS Code

Install [Go extension](https://marketplace.visualstudio.com/items?itemName=golang.go) and add to `settings.json`:

```json
{
  "go.lintTool": "golangci-lint",
  "go.lintFlags": ["--fast"],
  "go.lintOnSave": "workspace"
}

GoLand/IntelliJ IDEA

  1. Settings → Tools → File Watchers → Add (+)
  2. Select "golangci-lint"
  3. Configure: golangci-lint run $FileDir$

Vim/Neovim

With ale plugin:

let g:ale_linters = {'go': ['golangci-lint']}
let g:ale_go_golangci_lint_options = '--fast'

Additional Resources

  • Official documentation: https://golangci-lint.run
  • Configuration reference: https://golangci-lint.run/usage/configuration/
  • Linters list: https://golangci-lint.run/usage/linters/
  • GitHub repository: https://github.com/golangci/golangci-lint
  • Editor integrations: https://golangci-lint.run/usage/integrations/

Expected Output

After using this skill, your project will have:

  • Professional .golangci.yml configuration with 90+ linters
  • Balanced settings (strict but pragmatic)
  • CI/CD integration ready
  • Editor integration support
  • Fast, cached linting
  • Automated code quality enforcement

Your Go code will meet professional quality standards with comprehensive checks for bugs, security issues, performance problems, and best practices.

Du fichier au premier essai

Le téléchargement contient exactement le contenu affiché sur cette fiche. Cette copie peut différer de la dernière version du dépôt source.

Consulter la source et ses fichiers annexes

Ce téléchargement contient uniquement SKILL.md. Les scripts, références, modèles et dépendances éventuels ne sont pas inclus. Récupérez les fichiers nécessaires depuis la source en conservant leur arborescence avant de poursuivre.

1. Télécharger le fichier

Télécharger SKILL.md

Depuis la racine d’un projet de test, enregistrez le fichier sous .skill-downloads/golangci-lint-configuration-for-go-mmh8qrku/SKILL.md, ou utilisez la commande suivante. Ce dossier sert à examiner la skill avant son installation.

Commande pour macOS/Linux ou WSL : un shell POSIX et curl sont nécessaires. Sous Windows sans WSL, utilisez le bouton de téléchargement et créez le dossier manuellement.

mkdir -p '.skill-downloads/golangci-lint-configuration-for-go-mmh8qrku' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/golangci-lint-configuration-for-go-mmh8qrku/download' --output '.skill-downloads/golangci-lint-configuration-for-go-mmh8qrku/SKILL.md.part' && mv '.skill-downloads/golangci-lint-configuration-for-go-mmh8qrku/SKILL.md.part' '.skill-downloads/golangci-lint-configuration-for-go-mmh8qrku/SKILL.md'

2. Vérifier les prérequis

Lisez SKILL.md avant de l’utiliser. Si le fichier cite des scripts ou services externes, examinez-les et préparez les accès nécessaires dans votre environnement de test.

Extrait original : Prerequisites
  1. Go installed: Go 1.21+ recommended (go version)
  2. golangci-lint installed: Version 2.4.0+
    • macOS: brew install golangci-lint
    • Other: go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
    • Verify: golangci-lint --version
  3. Go module: Project uses Go modules (go.mod exists)

Les plateformes de la fiche sont des indications du catalogue. Les chemins ci-dessous suivent la documentation des outils ; ils ne prouvent pas que cette skill y a été exécutée. Aucune version minimale de ces outils n’est attestée pour cette fiche.

3. Charger la skill

Après vérification, copiez le dossier complet dans le projet avec l’une des commandes ci-dessous, puis ouvrez une nouvelle session de l’outil. La commande s’arrête si un dossier du même nom existe déjà : comparez les fichiers avant de le remplacer.

Claude Code
test -f '.skill-downloads/golangci-lint-configuration-for-go-mmh8qrku/SKILL.md' && test -s '.skill-downloads/golangci-lint-configuration-for-go-mmh8qrku/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/golangci-lint' && cp -R '.skill-downloads/golangci-lint-configuration-for-go-mmh8qrku' '.claude/skills/golangci-lint'

OpenSkills

OpenSkills doit déjà être installé. La procédure locale install/read est contrôlée avec OpenSkills 1.5.0, qui exige Node.js ≥ 20.6.0. Aucun slug du catalogue n’est résolu automatiquement.

Installation officielle d’OpenSkills
openskills install './.skill-downloads/golangci-lint-configuration-for-go-mmh8qrku'

openskills read 'golangci-lint-configuration-for-go-mmh8qrku'

La lecture doit afficher le contenu du fichier installé et son dossier de base. Elle ne lance ni la skill ni ses dépendances.

Pour un agent qui lit AGENTS.md, synchronisez ensuite l’index. Cette commande modifie AGENTS.md : relisez le diff avant de l’utiliser.

openskills sync

Mode manuel ou autre outil : joignez SKILL.md à une conversation, ou ouvrez-le dans un agent capable de lire les fichiers. Ajoutez les ressources annexes nécessaires. Il n’existe pas de dossier universel reconnu par tous les outils.

4. Faire un premier essai

Utilisez une entrée courte et fictive : un endpoint d’API, un petit document ou un brief d’interface. Dans une nouvelle conversation, joignez le fichier ou donnez son chemin à l’agent, puis adaptez cette demande :

Lis .skill-downloads/golangci-lint-configuration-for-go-mmh8qrku/SKILL.md et applique ses instructions à cet exemple : [décrire une entrée de test]. Indique les fichiers, dépendances ou accès qui manquent. Produis le résultat demandé par la skill sans inventer de données ni exécuter de script non examiné.

Résultat attendu : une sortie correspondant aux instructions de la skill, ou une liste précise des prérequis manquants. Une simple confirmation de lecture ne valide pas le premier usage. Si une ressource externe est indisponible, ce parcours reste à tester.

Skills similaires