samber/golang-how-to

Orchestrateur de compétences Go — toujours actif sur toute tâche de codage, revue, débogage ou configuration Go. Lit le contexte de la tâche et charge les compétences les plus pertinentes depuis samber/cc-skills-golang, souvent plusieurs à la fois.

Qu'est-ce que golang-how-to ?

Cette compétence orchestre l'utilisation d'autres compétences Go spécialisées (contenues dans `samber/cc-skills-golang`) en fonction de l'intention de la tâche. Elle ne fait pas elle-même de codage, mais agit comme un aiguilleur : pour une tâche donnée, elle identifie la compétence principale et toutes les compétences secondaires pertinentes (ex : écrivez un service gRPC → `golang-grpc` + `golang-testing` + `golang-error-handling`). Elle prend en charge les modes Orchestrate (chargement multiple simultané), Disambiguate (tableau de démarcation entre compétences qui se chevauchent) et Configure (écriture du fichier de configuration d'agent du projet, comme CLAUDE.md ou AGENTS.md, pour forcer le déclenchement de compétences). Elle s'appuie sur `gopls` pour la navigation dans le code source local et distingue son rôle de celui de `godig` (écosystème publié), Context7 (documentation générique) et govulncheck (vulnérabilités dans le build). Utile pour les développeurs utilisant Claude Code, Cursor, Codex ou tout agent IA qui doit appliquer des pratiques Go idiomatiques de manière cohérente.

Compatible avec✓Claude Code✓Codex CLI✓Cursor✓Gemini CLI
npx skills add https://github.com/samber/cc-skills-golang/tree/main/skills/golang-how-to

Installed? Explore more Développement et programmation skills: steipete/bluebubbles, steipete/eightctl, steipete/blucli · View all 6 →

Demander à votre IA préférée

Ouvre une nouvelle conversation avec cette compétence d'agent déjà préchargée.

Documentation

Persona : Vous êtes un orchestrateur de compétences Go. Pour chaque tâche Go, identifiez toutes les compétences pertinentes et chargez-les ensemble — une tâche appartient rarement à une seule compétence.

Modes :

  • Orchestrer — pour toute tâche de codage, revue, débogage ou configuration Go, chargez la compétence principale ainsi que toutes les compétences secondaires applicables simultanément.
  • Désambiguïser — lorsque deux compétences semblent se chevaucher, affichez le tableau des limites. Voir disambiguation.md.
  • Configurer — écrivez la directive de chargement permanent pour golang-how-to lui-même, ainsi qu'un bloc optionnel ## Required Go skills, dans le fichier de configuration de l'agent du projet (CLAUDE.md, AGENTS.md, ou équivalent). Suivez project-config.md.

Questions : En mode Configurer, posez la question via l'outil de question de l'environnement — jamais en texte brut. Une question à la fois, attendez la réponse. Si l'environnement n'a pas d'outil de question, demandez en prose avec les mêmes options.

Dépendances : gopls — go install golang.org/x/tools/gopls@latest ; l'outil LSP intégré de Claude Code nécessite également ENABLE_LSP_TOOL=1 et un serveur de langage Go configuré (voir Code navigation with gopls).

Chargement des compétences

Pour chaque tâche, chargez la compétence principale et toutes les compétences secondaires applicables en même temps. N'attendez pas — chargez-les ensemble dès le début.

IntentionPrincipaleCharger aussi
Concevoir une API, choisir un patterngolang-design-patternsgolang-structs-interfaces, golang-naming
Nommer un type, une fonction ou un packagegolang-naminggolang-code-style
Gérer les erreurs de manière idiomatiquegolang-error-handlinggolang-safety (code chargé en nil)
Écrire des goroutines, canaux, synchronisationgolang-concurrencygolang-context (si annulation)
Passer des délais / annuler des opérationsgolang-contextgolang-concurrency (si goroutines)
Concevoir des structs, embed, utiliser des interfacesgolang-structs-interfacesgolang-design-patterns
Requêtes et transactions en base de donnéesgolang-databasegolang-error-handling, golang-security
Construire un service gRPCgolang-grpcgolang-testing, golang-error-handling
Construire une API GraphQLgolang-graphqlgolang-testing, golang-error-handling
Construire un arbre de commandes CLIgolang-spf13-cobragolang-cli, golang-spf13-viper (si config)
Superposer la configuration depuis les flags/fichier/envgolang-spf13-vipergolang-spf13-cobra
Écrire des testsgolang-testinggolang-stretchr-testify (si utilisation de testify)
Appliquer des patterns d'optimisationgolang-performancegolang-benchmark (mesurer d'abord)
Mesurer avec pprof / benchstatgolang-benchmarkgolang-performance (corriger), golang-troubleshooting (cause racine)
Déboguer une panique ou un comportement inattendugolang-troubleshootinggolang-safety, golang-benchmark (si lié aux perfs)
Surveiller en productiongolang-observabilitygolang-performance (si violation de SLO)
Auditer les vulnérabilités de sécuritégolang-securitygolang-safety, golang-lint
Réviser le formatage et le stylegolang-code-stylegolang-naming, golang-lint
Refactoriser ou restructurer du code existantgolang-refactoringgolang-naming, golang-code-style, golang-project-layout
Configurer golangci-lintgolang-lintgolang-code-style
Écrire godoc / README / CHANGELOGgolang-documentationgolang-naming
Mettre en place une nouvelle structure de projetgolang-project-layoutgolang-design-patterns, golang-dependency-injection, golang-lint
Mettre en place un pipeline CI/CDgolang-continuous-integrationgolang-lint, golang-security
Choisir une bibliothèquegolang-popular-librariescompétence spécifique à la bibliothèque concernée
Consulter la documentation, les versions, les importeurs ou les CVE d'un packagegolang-pkg-go-devgolang-dependency-management
Naviguer, diagnostiquer ou refactoriser du code local (définitions, références, renommer)golang-gopls—
Adopter les nouvelles fonctionnalités du langage Gogolang-modernizegolang-lint
Utiliser samber/lo (helpers slice/map)golang-samber-logolang-data-structures, golang-performance
Utiliser samber/oops (erreurs structurées)golang-samber-oopsgolang-error-handling
Utiliser log/sloggolang-samber-sloggolang-observability, golang-error-handling
Utiliser l'injection de dépendancesgolang-dependency-injectiongolang-google-wire ou golang-uber-dig ou golang-uber-fx ou golang-samber-do

Tous les identifiants de compétences ci-dessus sont des formes courtes de samber/cc-skills-golang@<nom>.

Code navigation with gopls

gopls offre une intelligence sémantique du code pour Go — aller à la définition, rechercher des références, diagnostics, API de package, recherche de symboles, refactorisation. → Voir la compétence samber/cc-skills-golang@golang-gopls pour les trois façons d'y accéder (son propre serveur MCP, l'outil natif LSP et son CLI), la matrice complète des capacités et les workflows efficaces de lecture/édition.

gopls ne raisonne que sur le code présent et résoluble dans le build local : votre espace de travail plus chaque dépendance exactement comme épinglée dans go.sum (y compris les directives replace). Pour tout fait qui n'est pas lié à votre build local — historique des versions, licences, importeurs à l'échelle de l'écosystème, un package que vous n'avez pas encore ajouté — utilisez golang-pkg-go-dev (godig). Voir la section godig vs gopls vs Context7 vs govulncheck ci-dessous pour les limites complètes.

godig vs gopls vs Context7 vs govulncheck

Quatre outils peuvent répondre à la question "cette dépendance est-elle sûre à utiliser", et ils ne se chevauchent pas autant qu'ils en ont l'air :

  • Context7 est un récupérateur de documentation généraliste, multilingue — utile lorsqu'aucune source plus spécifique n'existe. Pour un package ou module Go, godig est presque toujours le meilleur choix : il extrait des données structurées et spécifiques à Go directement de pkg.go.dev — versions exactes, symboles exportés avec signatures, exemples exécutables, imported-by et vulnérabilités connues — plutôt que la documentation générique raclée/curatée de Context7, qui n'expose pas cette structure et peut prendre du retard ou manquer des modules Go moins connus. Utilisez Context7 uniquement lorsque la documentation d'une dépendance n'existe vraiment pas ou n'est pas indexée sur pkg.go.dev.
  • godig répond aux questions sur l'écosystème publié : tout package ou module Go, qu'il soit ou non dans votre go.mod — il appelle l'API distante de pkg.go.dev et ne touche jamais à votre checkout local. Sa commande vulns signale les CVE connues pour un package/version de manière isolée, indépendamment du fait que votre build atteigne réellement le chemin de code vulnérable.
  • gopls (→ samber/cc-skills-golang@golang-gopls, via son serveur MCP, l'outil natif LSP ou son CLI) répond aux questions sur votre build spécifique : votre code plus chaque dépendance

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

samber/golang-benchmark

Golang benchmarking, profiling, and performance measurement. Use when writing, running, or comparing Go benchmarks, profiling hot paths with pprof, interpreting CPU/memory/trace profiles, analyzing results with benchstat, setting up CI benchmark regression detection, or investigating production performance with Prometheus runtime metrics. Also use when the developer needs deep analysis on a specific performance indicator - this skill provides the measurement methodology, while `samber/cc-skills-golang@golang-performance` provides the optimization patterns.

samber/golang-cli

Golang CLI application development. Use when building, modifying, or reviewing a Go CLI tool — especially for command structure, flag handling, configuration layering, version embedding, exit codes, I/O patterns, signal handling, shell completion, argument validation, and CLI unit testing. Also triggers when code uses cobra, viper, or urfave/cli. For cobra-specific APIs → See `samber/cc-skills-golang@golang-spf13-cobra` skill; for viper configuration layering → See `samber/cc-skills-golang@golang-spf13-viper` skill.

samber/golang-code-style

Golang code style conventions — line length and breaking, variable declarations, control flow clarity, when comments help vs hurt. Use when writing or reviewing Go code, asking about style or clarity, or establishing project coding standards. Not for naming conventions (→ See `samber/cc-skills-golang@golang-naming` skill), linter configuration (→ See `samber/cc-skills-golang@golang-lint` skill), or doc comments (→ See `samber/cc-skills-golang@golang-documentation` skill).

samber/golang-concurrency

Golang concurrency patterns. Use when writing or reviewing concurrent Go code involving goroutines, channels, select, locks, sync primitives, errgroup, singleflight, worker pools, or fan-out/fan-in pipelines. Also triggers when you detect goroutine leaks, race conditions, channel ownership issues, or need to choose between channels and mutexes.

samber/golang-context

Idiomatic context.Context usage in Golang — propagation through API boundaries, cancellation, timeouts and deadlines, request-scoped values, context.WithoutCancel for background work outliving requests. Apply when designing context propagation across layers, debugging leaked or unexpired contexts, choosing between context.Background/TODO/WithoutCancel, or storing values in context. Not for code that merely accepts ctx as first parameter.

samber/golang-continuous-integration

CI/CD pipeline configuration using GitHub Actions for Golang projects — testing, linting, SAST, security scanning, code coverage, Dependabot, Renovate, GoReleaser, code review automation, and release pipelines. Use when setting up or improving Go project CI, configuring GitHub Actions workflows, adding linters or security scanners, automating dependency updates, or adding quality gates.

samber/golang-database

Comprehensive guide for Go database access — parameterized queries, struct scanning, NULLable columns, transactions, isolation levels, SELECT FOR UPDATE, connection pool, batch processing, context propagation, and migration tooling. Use when writing, reviewing, or debugging Golang code that interacts with PostgreSQL, MariaDB, MySQL, or SQLite; for database testing; or for questions about database/sql, sqlx, or pgx. Does NOT generate database schemas or migration SQL.

samber/golang-data-structures

Golang data structures — slices (internals, capacity growth, preallocation, slices package), maps (internals, hash buckets, maps package), arrays, container/list/heap/ring, strings.Builder vs bytes.Buffer, generic collections, pointers (unsafe.Pointer, weak.Pointer), and copy semantics. Use when choosing or optimizing Go data structures, implementing generic containers, using container/ packages, unsafe or weak pointers, or questioning slice/map internals.

samber/golang-dependency-injection

Comprehensive guide for dependency injection (DI) in Golang. Covers why DI matters (testability, loose coupling, separation of concerns, lifecycle management), manual constructor injection, and DI library comparison (google/wire, uber-go/dig, uber-go/fx, samber/do). Use this skill when designing service architecture, setting up dependency injection, refactoring tightly coupled code, managing singletons or service factories, or when the user asks about inversion of control, service containers, or wiring dependencies in Go. For a specific DI library, → See `samber/cc-skills-golang@golang-google-wire`, `samber/cc-skills-golang@golang-uber-dig`, `samber/cc-skills-golang@golang-uber-fx`, or `samber/cc-skills-golang@golang-samber-do` skills.

samber/golang-dependency-management

Dependency management strategies for Golang projects — go.mod management, installing/upgrading packages, Minimal Version Selection, vulnerability scanning, outdated dependency tracking, binary size analysis, Dependabot/Renovate setup, conflict resolution, and go.work workspaces. Use when adding, removing, or upgrading Go dependencies, auditing vulnerabilities, resolving version conflicts, or setting up automated dependency updates.

samber/golang-design-patterns

Idiomatic Golang design patterns — functional options, constructors, error flow and cascading, resource management and lifecycle, graceful shutdown, resilience, architecture, dependency injection, data handling, streaming, and more. Apply when explicitly choosing between architectural patterns, implementing functional options, designing constructor APIs, setting up graceful shutdown, applying resilience patterns, or asking which idiomatic Go pattern fits a specific problem.

samber/golang-documentation

Comprehensive documentation guide for Golang projects, covering godoc comments, README, CONTRIBUTING, CHANGELOG, Go Playground, Example tests, API docs, and llms.txt. Use when writing or reviewing doc comments, documentation, adding code examples, setting up doc sites, or discussing documentation best practices. Triggers for both libraries and applications/CLIs.

samber/golang-error-handling

Idiomatic Golang error handling — creation, wrapping with %w, errors.Is/As, errors.Join, custom error types, sentinel errors, panic/recover, the single handling rule, structured logging with slog, HTTP request logging middleware, and samber/oops for production errors. Built to make logs usable at scale with log aggregation 3rd-party tools. Apply when creating, wrapping, inspecting, or logging errors in Go code. For samber/oops specifics → See `samber/cc-skills-golang@golang-samber-oops` skill; for slog handler ecosystem → See `samber/cc-skills-golang@golang-samber-slog` skill.

samber/golang-google-wire

Compile-time dependency injection in Golang using google/wire — wire.NewSet, wire.Build, wire.Bind (interface→concrete), wire.Struct, wire.Value, wire.InterfaceValue, wire.FieldsOf, cleanup functions, //go:build wireinject injector files, and generated wire_gen.go. Apply when using or adopting google/wire, when the codebase imports `github.com/google/wire`, or when wiring an application graph at compile time via `wire.Build`. For runtime DI with reflection, see `samber/cc-skills-golang@golang-uber-dig` skill.

samber/golang-gopls

Golang semantic code intelligence via `gopls`, the official Go language server — go-to-definition, find references, call/implementation hierarchy, workspace symbol search, package API discovery, diagnostics, safe rename, refactors (extract/inline/fill/rewrite code actions), formatting, and generated tests. Reaches an agent via gopls's own MCP server (`go_*` tools), Claude Code's native `LSP` tool, or the `gopls` CLI. Use when navigating or refactoring Go code — jumping to a definition, finding call sites before a rename, understanding a file's or package's dependencies, running diagnostics after an edit, or extracting/inlining/renaming. Not for the published ecosystem — packages not in your `go.mod`, versions, licenses, importers — → See `samber/cc-skills-golang@golang-pkg-go-dev` skill (`godig`). Not for a whole-tree vulnerability audit → See `samber/cc-skills-golang@golang-security` skill (`govulncheck`).

samber/golang-graphql

Implements GraphQL APIs in Golang using gqlgen or graphql-go. Apply when building GraphQL servers, designing schemas, writing resolvers, handling subscriptions, or integrating GraphQL with existing Go HTTP services. Also apply when the codebase imports `github.com/99designs/gqlgen` or `github.com/graph-gophers/graphql-go`.

samber/golang-grpc

Provides gRPC usage guidelines, protobuf organization, and production-ready patterns for Golang microservices. Use when implementing, reviewing, or debugging gRPC servers/clients, writing proto files, setting up interceptors, handling gRPC errors with status codes, configuring TLS/mTLS, testing with bufconn, or working with streaming RPCs.

samber/golang-lint

Linting best practices and golangci-lint configuration for Golang projects — running linters, configuring .golangci.yml, suppressing warnings with nolint directives, interpreting lint output, and selecting linters. Use when configuring golangci-lint, asking about lint warnings or nolint suppressions, setting up code quality tooling, or choosing linters. Also use when the user mentions golangci-lint, go vet, staticcheck, or revive.

samber/golang-modernize

Modernize Golang code to use recent language features, standard library improvements, and idiomatic patterns. Trigger proactively when writing or reviewing Go code and old-style patterns are detected, or when encountering a deprecation warning. Also use when the user explicitly asks for modernization, a Go version upgrade, or a CI/tooling refresh.

samber/golang-naming

Go (Golang) naming conventions — covers packages, constructors, structs, interfaces, constants, enums, errors, booleans, receivers, getters/setters, functional options, acronyms, test functions, and subtest names. Use this skill when writing new Go code, reviewing or refactoring, choosing between naming alternatives (New vs NewTypeName, isConnected vs connected, ErrNotFound vs NotFoundError, StatusReady vs StatusUnknown at iota 0), debating Go package names (utils/helpers anti-patterns), or asking about Go naming best practices. Also trigger when the user mentions MixedCaps vs snake_case, ALL_CAPS constants, Get-prefix on getters, or error string casing. Do NOT use for general Go implementation questions that don't involve naming decisions.

Skills associés