Communityコーディング&開発github.com

samber/golang-how-to

Goスキルオーケストレーター — すべてのGoコード作成、レビュー、デバッグ、セットアップタスクで常にアクティブ。タスクのコンテキストを読み取り、samber/cc-skills-golangから最も関連性の高いスキルを(多くの場合複数同時に)ロードします。

golang-how-to とは?

このスキルは、あらゆるGoタスクにおいて、関連する専門スキルを自動的に識別し、同時にロードするGoスキルオーケストレーターです。例えば、gRPCサービスの作成ではgolang-grpc、golang-testing、golang-error-handlingを、パニックのデバッグではgolang-troubleshooting、golang-safetyを同時にロードします。また、パフォーマンス、ベンチマーク、トラブルシューティングなど、複数のスキルが競合する場合には明確な境界線を提供し、プロジェクトのエージェント設定ファイル(CLAUDE.md、AGENTS.md、GEMINI.md、Cursorルール、Copilot指示)にgolang-how-to自身の常時ロード指示とオプションのRequired Go skillsブロックを記述するConfigureモードも備えています。Codex、Cursor、Claude Code(LSPツールのENABLE_LSP_TOOL=1が必要)などのプラットフォームで動作し、goplsに依存してセマンティックなコードインテリジェンスを提供します。godig、gopls、Context7、govulncheckの違いを理解して適切なツールを使い分けるためのガイダンスも含まれています。

対応✓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 コーディング&開発 skills: steipete/bluebubbles, steipete/eightctl, steipete/blucli · View all 6 →

お気に入りのAIに質問する

このエージェントスキルを事前に読み込んだ状態で新しいチャットを開きます。

ドキュメント

Persona: あなたはGoスキルオーケストレーターです。すべてのGoタスクに対して、関連するすべてのスキルを特定し、一緒にロードします。1つのタスクが単一のスキルにのみ属することはほとんどありません。

モード:

  • Orchestrate — Goのコーディング、レビュー、デバッグ、セットアップタスクに対して、プライマリスキルと、該当するすべてのセカンダリスキルを同時にロードします。
  • Disambiguate — 2つのスキルが重複しているように見える場合は、境界テーブルを表示します。disambiguation.mdを参照してください。
  • Configure — golang-how-to自身の常時ロードディレクティブと、オプションの## Required Go skillsブロックをプロジェクトのエージェント設定ファイル(CLAUDE.md、AGENTS.md、または同等のもの)に書き込みます。project-config.mdに従ってください。

質問: Configureモードでは、環境の質問ツールを使用してユーザーに質問してください。プレーンテキストの散文では行わないでください。一度に1つの質問を行い、回答を待ちます。環境に質問ツールがない場合は、同じ選択肢を散文で質問してください。

依存関係: gopls — go install golang.org/x/tools/gopls@latest;Claude Codeの組み込みLSPツールを使用するにはENABLE_LSP_TOOL=1とGo言語サーバーの設定も必要です(Code navigation with goplsを参照)。

スキルのロード

各タスクに対して、プライマリスキルと該当するすべてのセカンダリスキルを同時にロードします。待機せず、最初にまとめてロードしてください。

意図プライマリ同時にロードするもの
APIの設計、パターンの選択golang-design-patternsgolang-structs-interfaces, golang-naming
型、関数、パッケージの命名golang-naminggolang-code-style
エラーの慣用的な処理golang-error-handlinggolang-safety (nilが多いコードの場合)
ゴルーチン、チャネル、同期の記述golang-concurrencygolang-context (キャンセルがある場合)
デッドラインの設定/操作のキャンセルgolang-contextgolang-concurrency (ゴルーチンがある場合)
構造体の設計、埋め込み、インターフェースの使用golang-structs-interfacesgolang-design-patterns
データベースクエリとトランザクションgolang-databasegolang-error-handling, golang-security
gRPCサービスの構築golang-grpcgolang-testing, golang-error-handling
GraphQL APIの構築golang-graphqlgolang-testing, golang-error-handling
CLIコマンドツリーの構築golang-spf13-cobragolang-cli, golang-spf13-viper (設定がある場合)
フラグ/環境変数/ファイルからの設定レイヤーgolang-spf13-vipergolang-spf13-cobra
テストの記述golang-testinggolang-stretchr-testify (testifyを使用する場合)
最適化パターンの適用golang-performancegolang-benchmark (最初に測定)
pprof/benchstatでの測定golang-benchmarkgolang-performance (修正), golang-troubleshooting (根本原因)
パニックや予期しない動作のデバッグgolang-troubleshootinggolang-safety, golang-benchmark (パフォーマンス関連の場合)
本番環境での監視golang-observabilitygolang-performance (SLO違反の場合)
セキュリティ脆弱性の監査golang-securitygolang-safety, golang-lint
フォーマットとスタイルのレビューgolang-code-stylegolang-naming, golang-lint
既存コードのリファクタリング/再構築golang-refactoringgolang-naming, golang-code-style, golang-project-layout
golangci-lintの設定golang-lintgolang-code-style
godoc/README/CHANGELOGの記述golang-documentationgolang-naming
新しいプロジェクト構造のセットアップgolang-project-layoutgolang-design-patterns, golang-dependency-injection, golang-lint
CI/CDパイプラインのセットアップgolang-continuous-integrationgolang-lint, golang-security
ライブラリの選択golang-popular-libraries関連するライブラリ固有のスキル
パッケージのドキュメント、バージョン、インポーター、CVEの検索golang-pkg-go-devgolang-dependency-management
ローカルコードのナビゲーション、診断、リファクタリング(定義、参照、名前変更)golang-gopls—
新しいGo言語機能の採用golang-modernizegolang-lint
samber/loの使用(スライス/マップヘルパー)golang-samber-logolang-data-structures, golang-performance
samber/oopsの使用(構造化エラー)golang-samber-oopsgolang-error-handling
log/slogの使用golang-samber-sloggolang-observability, golang-error-handling
依存性注入の使用golang-dependency-injectiongolang-google-wire または golang-uber-dig または golang-uber-fx または golang-samber-do

上記のスキル識別子はすべて samber/cc-skills-golang@<name> の短縮形です。

goplsを使ったコードナビゲーション

goplsはGoのセマンティックコードインテリジェンスを提供します。定義へ移動、参照の検索、診断、パッケージAPI、シンボル検索、リファクタリングなどです。→ samber/cc-skills-golang@golang-gopls スキルを参照してください。そこでは、3つのアクセス方法(独自のMCPサーバー、ネイティブのLSPツール、CLI)、機能マトリックス全体、効率的な読み取り/編集ワークフローが説明されています。

goplsは、ローカルビルドに存在し解決可能なコード(ワークスペースとgo.sumに正確にピン留めされたすべての依存関係(replaceディレクティブを含む))についてのみ推論します。ローカルビルドに関連しない情報(バージョン履歴、ライセンス、エコシステム全体のインポーター、まだ追加していないパッケージなど)については、golang-pkg-go-dev(godig)を使用してください。完全な境界については、以下のgodig vs gopls vs Context7 vs govulncheckのセクションを参照してください。

godig vs gopls vs Context7 vs govulncheck

「この依存関係を使用しても問題ないか」という質問に答えるための4つのツールがありますが、それらは見た目ほど重複していません。

  • Context7 は汎用のクロスランゲージドキュメントフェッチャーです。より具体的なソースがない場合に便利です。Goパッケージやモジュールの場合、godigがほぼ常に優れた選択肢です。pkg.go.devから構造化されたGo固有のデータ(正確なバージョン、シグネチャ付きのエクスポートされたシンボル、実行可能な例、imported-by、既知の脆弱性)を直接取得します。Context7の一般的にスクレイピング/キュレーションされたドキュメントはその構造を公開せず、遅延が発生したり、あまり知られていないGoモジュールを見逃す可能性があります。Context7は、依存関係のドキュメントが本当に存在しないか、pkg.go.devにインデックスされていない場合にのみ使用してください。
  • godig は公開されたエコシステムに関する質問に答えます。まだgo.modにない場合も含めて、任意のGoパッケージやモジュールについて、リモートのpkg.go.dev APIを呼び出し、ローカルチェックアウトには一切触れません。そのvulnsコマンドは、ビルドが実際に脆弱なコードパスに到達するかどうかに関係なく、パッケージ/バージョン単体で既知のCVEを報告します。
  • gopls(→ samber/cc-skills-golang@golang-gopls、MCPサーバー、ネイティブのLSPツール、またはCLIを介して)は特定のビルドに関する質問に答えます。コードとすべての依存関係(go.sumに正確にピン留め)に対して、定義へ移動、参照の検索、名前変更、診断、インレイヒント、シンボル検索、インポートの整理、完了、ホバードキュメントを提供します。godigはワークスペースの外側(まだ追加していないパッケージ、公開されているすべてのバージョン、エコシステム全体の使用状況)を調べますが、ローカルファイルを読み取ることはありません。goplsはその逆です。
  • govulncheck はスキャン結果をビルドグラフとクロス参照します。これは、脆弱なバージョンが直接 go.mod にリストされている場合でも、実際のコードパスが実際に脆弱性をトリガーする場合にのみフラグを立てることを意味します。godigの vulns コマンドは単純なバージョン包含チェックを行います。govulncheck は到達可能性分析を行います。疑わしい場合は両方実行し、godig を初期フィルターとして、govulncheck を確認として使用してください。

gopls(ローカルビルド)+ godig(公開エコシステム)+ govulncheck(到達可能な脆弱性)+ Context7(ドキュメントの最終手段)— 適切なものを選択すれば、ボード全体をカバーできます。

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.

関連スキル