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

samber/golang-gopls

Golang のセマンティックコードインテリジェンスを `gopls` 公式 Go 言語サーバー経由で提供します。定義ジャンプ、参照検索、呼び出し/実装階層、ワークスペースシンボル検索、パッケージ API 探索、診断、安全なリネーム、リファクタリング(抽出/インライン化/補完/コードアクションの書き換え)、フォーマット、テスト生成を行います。エージェントは gopls 独自の MCP サーバー(`go_*` ツール)、Claude Code のネイティブ `LSP` ツール、または `gopls` CLI を介して利用できます。Go コードのナビゲーションやリファクタリング時に使用します — 定義へのジャンプ、リネーム前の呼び出し箇所の検索、ファイルやパッケージの依存関係の把握、編集後の診断の実行、抽出/インライン化/リネームなど。公開エコシステム(`go.mod` にないパッケージ、バージョン、ライセンス、インポーター)には対応しません → `samber/cc-skills-golang@golang-pkg-go-dev` スキル(`godig`)を参照。ツリー全体の脆弱性監査には対応しません → `samber/cc-skills-golang@golang-security` スキル(`govulncheck`)を参照。

golang-gopls とは?

このスキルは、公式 Go 言語サーバー `gopls` を活用して、Go コードベースに対する高度なセマンティックコードインテリジェンスを AI エージェント(Claude Code など)に提供します。定義へのジャンプ、参照の検索、呼び出し階層の追跡、シンボル検索、パッケージ API の探索、リアルタイム診断、安全なリネーム、そして抽出・インライン化・補完などのリファクタリング機能を備えています。エージェントは、gopls 独自の MCP サーバー(`go_*` ツール)、Claude Code のネイティブ `LSP` ツール、または `gopls` CLI の 3 つの経路でこのインテリジェンスにアクセスできます。ワークスペースのレイアウト確認、シンボル検索、ファイルのコンテキスト取得、パッケージ API の探索を含む推奨の読み取りワークフローと、編集後の診断と脆弱性チェックを含む編集ワークフローが用意されており、開発者はコードベースを効率的に理解・リファクタリングできます。このスキルはローカルに解決されたビルドにのみ対応し、公開パッケージエコシステムの探索や包括的な脆弱性監査は対象外です。

対応✓Claude Code✓Codex CLI✓Cursor
npx skills add https://github.com/samber/cc-skills-golang/tree/main/skills/golang-gopls

Installed? Explore more コーディング&開発 skills: steipete/bluebubbles, steipete/eightctl, steipete/blucli · View all 6 →

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

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

ドキュメント

ペルソナ: あなたは、解決済みビルドに関する質問に答える際に、grep ではなくセマンティックコードインテリジェンスを利用する Go エンジニアです。grep はテキストを探し、gopls は意味(型、呼び出しグラフ、シャドーイング、実装関係)を探します。

依存関係: gopls — go install golang.org/x/tools/gopls@latest(v0.20+)を実行してください。ネイティブの LSP ツールを使用するには、さらに ENABLE_LSP_TOOL=1 の設定と、gopls-lsp@claude-plugins-official マーケットプレイスプラグインのインストールが必要です(references/mcp.md を参照)。

gopls は公式の Go 言語サーバーです。これはあなたの特定の、ローカルに解決されたビルド、つまりあなたのワークスペースと、go.sum に正確にピン留めされたすべての依存関係(replace ディレクティブを含む)についてのみ回答します。そのビルドに含まれないパッケージ(まだ追加していないもののバージョン、ドキュメント、ライセンス、CVE)については、代わりに samber/cc-skills-golang@golang-pkg-go-dev スキル(godig)を参照してください。

gopls への3つのアクセス方法

これらは互換性がありません — 既に知っている情報と必要な出力に基づいて選択してください:

  • gopls 独自の MCP サーバー(ほとんどのタスクに推奨) — エージェント向けに設計されています:ツールは生のカーソル位置ではなく、名前、ファイルパス、あいまいクエリを受け取ります。マシンごとに一度登録:claude mcp add gopls -- gopls mcp。エディタなしで stdio 経由でヘッドレス動作し、ディスクに保存されたファイルのみを認識します — エージェント専用ワークフローに適したデフォルトです。すべてのツールについては references/mcp.md を参照してください。
  • ネイティブ LSP ツール — Claude Code 組み込みのエディタスタイル統合。デフォルトではオフ:ENABLE_LSP_TOOL=1 を設定し、gopls をインストールし、公式の gopls-lsp@claude-plugins-official マーケットプレイスプラグインをインストールして Go 言語サーバーとして配線します。操作(goToDefinition、findReferences、hover、documentSymbol、workspaceSymbol、goToImplementation、呼び出し階層)は line/character で指定されるため、既に位置が分かっている場合 — 通常は grep や読み取りの直後 — に最も便利です。ユニークな価値:コンパイラ診断が編集後に自動的にコンテキストにプッシュされるため、明示的な呼び出しは不要です。
  • gopls CLI — 同じエンジンを gopls <command> <file:line:col> として呼び出します。Go チームは実験的かつデバッグ専用として文書化しており — 「効率的、完全、柔軟、または公式にサポートされているわけではありません」。MCP もネイティブツールも配線されていない場合、または一度限りのスクリプトチェックに使用します。位置は file:line:col(1 始まり、UTF-8 バイト)または file:#offset(0 始まり)です。references/cli.md を参照してください。

優先順位:MCP → ネイティブ LSP → CLI。 MCP ツールはエージェントの思考方法(カーソル位置ではなく名前/パスで)に合致します。ネイティブツールは無料の自動診断を追加します。CLI は文書化された最後の手段のフォールバックです。利用可能なものはすべて配線し、タスクに適したツールを選択してください — 既に line:col が分かっているクエリは LSP で安価に、"X はどこにある" クエリは go_search で安価に、迅速な無人チェックは CLI で安価に行えます。

機能 → CLI → MCP → ネイティブ LSP

すべての機能の CLI コマンド、MCP ツール、ネイティブ LSP 操作への完全なマッピング:references/matrix.md。

ユースケース

  • ナビゲーション — 自分が書いていないコードに触れる前に、定義、実装にジャンプするか、呼び出しグラフをトレースします。詳細:references/features.md。
  • コード発見 — ワークスペースの形状を把握する(go_workspace)、正確に特定できないシンボルをあいまい検索する(go_search)、使用前に依存関係の公開サーフェスを読む(go_package_api)。
  • ドキュメント — 型/ドキュメント/サイズ情報のホバー、関数呼び出し中のシグネチャヘルプ、またはレンダリングされたパッケージドキュメントの参照(source.doc、pkg.go.dev では決して見られない内部パッケージを含む)。
  • 診断と安全性 — 編集後のコンパイラおよびアナライザエラー(go_diagnostics / LSP では自動)、および軽量な go_vulncheck 到達可能性チェック:ワークスペースを検出した直後のベースラインとして一度、そして go.mod の変更後にもう一度実行します。
  • フォーマット — 標準の gofmt 相当のフォーマットとインポート整理。スクリプト可能かつコードアクション駆動の両方をサポート。
  • リファクタリング — 安全なリネーム(インターフェースの満足を壊す変更をブロック)、抽出/インライン化、および refactor.rewrite.* ファミリー全体(構造体/スイッチの補完、if の反転、行の分割/結合、未使用パラメータの削除、構造体タグの追加、インターフェースの実装)。落とし穴を含む完全なカタログ:references/features.md。

効率的なワークフロー

以下の Read/Edit ワークフローは、冗長なクエリと中途半端な編集を避ける順序をエンコードしています — ラウンドトリップを節約するためでも、すべてのステップを必須として扱い、オプションと見なさないでください。

  • セッション開始 — go_workspace を一度呼び出して、これが Go ワークスペースかどうかを検出します。もしそうなら、直後にベースラインの go_vulncheck を実行し、ワークスペースがすでに持っている脆弱性を明らかにします。これは無条件であり、依存関係の変更後の編集ワークフローの後のチェックとは別です。

読み取りワークフロー(何かに触れる前に理解する):

  1. go_workspace — レイアウト(モジュール/ワークスペース/GOPATH)。上記のセッション開始チェックと同じ呼び出しです(まだ実行されていない場合)。
  2. go_search — 型/関数/変数を名前で曖昧検索します。
  3. go_file_context — 任意の Go ファイルを初めて読んだ直後に、そのファイルが同じパッケージの他の部分から何を引き込んでいるかを確認します。そのファイルの依存関係が変更された場合は再実行します。
  4. go_package_api — サードパーティの依存関係や兄弟パッケージの公開サーフェスを、すべてのファイルを読まずに確認します。

編集ワークフロー(診断がクリーンになるまで繰り返す):

  1. 最初に読み取り(上記ワークフロー)。
  2. 定義を変更する前に go_symbol_references を実行 — 影響範囲を評価し、一致する編集が必要なすべての参照ファイルを読みます。
  3. 参照サイトの編集を含め、計画されたすべての編集を行ってから次に進みます。
  4. 変更されたすべてのファイルで go_diagnostics を実行 — 各修正後は必須であり、オプションのクリーンアップパスではありません。
  5. 報告されたエラーを修正:提案されたクイックフィックス差分を適用前に確認し、その後診断を再実行して修正が適用されたことを確認します。タスクに関係のないヒント/情報診断は無視します。診断メッセージは、周囲のソースを逐語的に引用するのではなく、言い換えることができます。
  6. go.mod の依存関係が変更された場合にのみ、ワークスペース全体で go_vulncheck を実行 — 診断がクリーンになった後、前ではありません。
  7. go test <changed-package-paths> を実行 — 明示的に依頼がない限り ./... ではありません。

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-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-how-to

Golang skills orchestrator — always active on any Golang coding, review, debug, or setup task. Reads the task context and loads the most relevant skills from samber/cc-skills-golang, often multiple at once: writing a gRPC service loads golang-grpc + golang-testing + golang-error-handling; debugging a panic loads golang-troubleshooting + golang-safety; auditing security loads golang-security + golang-lint + golang-safety. Also: disambiguates competing clusters when two skills seem to overlap (performance vs benchmark vs troubleshooting, samber/lo vs mo vs ro, DI cluster, safety vs security), and configures the project's agent-config file (CLAUDE.md, AGENTS.md, GEMINI.md, Cursor rules, or Copilot instructions) to force-trigger skills in a project (/golang-how-to configure).

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.

関連スキル