Community程式設計與開發github.com

samber/golang-pkg-go-dev

透過 `godig`(pkg.go.dev API 客戶端)查詢 Go 套件與模組的文檔、符號、版本、授權、弱點及導入關係。只讀操作,無需認證。

golang-pkg-go-dev 是什麼?

此技能(由 `godig` 支援)讓 AI 代理能直接讀取 pkg.go.dev 的 API,以回答關於 Go 開放生態系的問題。它涵蓋了已發布套件的文檔(個別符號或整個套件)、執行範例、模組 README、許可證條款、可用版本與主版本,以及哪些套件導入此套件。內建漏洞查詢會參考 Go 漏洞資料庫,而 `overview` 指令則能快速提供摘要,節省 token 用量。技能適用於 Claude Code(透過 stdio 或 streamable HTTP 註冊 MCP 伺服器)、Cursor、Windsurf 及其他 MCP 相容主機。也提供代管實例(https://godig.samber.dev/mcp),無需安裝即可使用。所有指令皆可透過 CLI 或 MCP 操作存取。此技能專為唯讀查詢而設計;不應將其用於升級依賴項(請改用 golang-dependency-management 技能)、選擇熱門函式庫(請改用 golang-popular-libraries),或分析區域解析的建置內容(請改用 golang-gopls 技能)。

相容平台✓Claude Code✓Codex CLI✓Cursor✓Windsurf
npx skills add https://github.com/samber/cc-skills-golang/tree/main/skills/golang-pkg-go-dev

Installed? Explore more 程式設計與開發 skills: steipete/bluebubbles, steipete/eightctl, steipete/blucli · View all 6 →

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

golang-pkg-go-dev 是做什麼的?

相依項: godig — go install github.com/samber/godig/cmd/godig@latest(或改用已註冊的 godig MCP 伺服器 / 代管實例)。

godig 查詢 pkg.go.dev API。用於回答關於 Go 套件與模組的問題:文檔、符號、版本、導入者與弱點。它可作為 CLI 和 MCP 伺服器執行,所有操作皆為唯讀且無需認證。

使用此技能的時機

觸發於類似下列問題:

  • 「github.com/samber/lo 有哪些可用版本?」
  • 「golang.org/x/text 是否有已知弱點?」
  • 「顯示套件 X 的文檔 / 符號。」
  • 「哪些套件導入 X?」
  • 「搜尋 Go 套件中的 Y。」

在 godig、gopls、Context7 與 govulncheck 之間選擇

簡而言之:godig 回答關於已發布生態系的問題(即使套件尚未在您的 go.mod 中也能運作);gopls 推論您的區域解析建置(go.sum,包含 replace 的分支);Context7 是非 Go 或未索引文檔的備援方案;govulncheck 是完整樹狀的弱點稽核(→ samber/cc-skills-golang@golang-security)。請參閱 samber/cc-skills-golang@golang-gopls 技能以了解如何將 gopls(MCP 伺服器、原生 LSP 工具與 CLI)與 Claude Code 整合,以及 samber/cc-skills-golang@golang-how-to 技能的「godig vs gopls vs Context7 vs govulncheck」一節以取得完整的任務對應工具矩陣。

設定

安裝

go install github.com/samber/godig/cmd/godig@latest

註冊 MCP 伺服器(選用)

godig mcp 預設透過 stdio 執行,或透過 --transport http 使用 streamable HTTP。此指令與工具無關 — 任何 MCP 相容的主機均可指向它。Claude Code 透過其自己的 CLI 註冊:

stdio(客戶端隨需啟動 godig):

claude mcp add pkg-go-dev -- godig mcp

streamable HTTP(共享伺服器,端點在 /mcp,預設為 :8080):

godig mcp --transport http --addr :8080
claude mcp add --transport http pkg-go-dev http://localhost:8080/mcp

代管實例(無需安裝)— 公用伺服器執行於 https://godig.samber.dev/mcp:

claude mcp add --transport http pkg-go-dev https://godig.samber.dev/mcp

其他 MCP 相容工具(Cursor、Windsurf 及其他)各有其自己的 MCP 伺服器註冊方式 — 在其各自的設定檔中指向相同的 godig mcp 指令或代管 URL,而非共享的設定格式。

CLI 與 MCP 伺服器以相符的名稱公開相同的操作。當已安裝 godig 時偏好使用 CLI;代管實例則是在未安裝時的備援方案。

指令

全域旗標(所有指令): -o/--output table|json|raw|md(預設 table — 傳入 -o md 以用於聊天)、--base-url(pkg.go.dev API)、--vuln-base-url(Go 漏洞資料庫,由 vulns 和 overview 使用)、--timeout、--log-level debug|info|warn|error|off。所有項目也可透過 GODIG_* 環境變數設定。

指令參數特定旗標用途
overview<path>--version精簡摘要(中繼資料、版本、授權、弱點)— 從這裡開始
search<query>--symbol --limit --filter尋找套件(可選:匯出特定符號者)
package info<path>--module --version套件中繼資料
package imports<path>--module --version此套件導入的套件(純清單)
package doc<path>--module --version --goos --goarch --format md|text|html|markdown完整套件文檔(LARGE)
package examples<path>--module --version --goos --goarch --symbol可執行範例(LARGE;使用 --symbol 限定範圍)
package licenses<path>--module --version授權檔案,完整文字(LARGE)
symbol doc<path> <symbol>--module --version --goos --goarch單一符號的簽名 + 文檔(節省 token)
symbol examples<path> <symbol>--module --version --goos --goarch單一符號的可執行範例
symbols<path>--module --version --goos --goarch --limit --filter列出匯出的符號
module info<path>--version模組中繼資料
module licenses<path>--version模組授權檔案(LARGE)
module readme<path>--version模組 README,完整 Markdown(LARGE)
dependencies<path>--versiongo.mod 相依項:requires / replaces / excludes / go 指令
packages<path>--version --limit --filter模組中包含的套件
versions<path>--limit --filter所有版本,最新者優先
major-versions<path>--limit --filter --exclude-pseudo作為獨立模組存在的主版本(v1、v2 …)
imported-by<path>--module --version --limit --filter導入此套件的套件
vulns<path>--version --limit已知弱點(來自 Go 弱點資料庫)
mcp—--transport stdio|http --addr --cache-ttl --cache-size以 MCP 伺服器模式執行
version——顯示 godig 版本 / 提交 / 建置日期

當 godig 以 MCP 伺服器執行時,上述每個資料指令都會以同名操作公開。

退出碼: 0 成功,1 執行時期錯誤(網路、套件未找到),2 使用錯誤 — 缺少或無效的引數或旗標(例如非正數的 --limit),或指令群組呼叫時未附上子指令(godig package)。檢查 2 可區分格式錯誤的呼叫與查詢失敗。

每個指令的完整 -o md 輸出:sample-output.md。

提示

  • 從 overview 開始 — 一次呼叫即可回傳精簡摘要(中繼資料、最新 + 近期版本、授權類型、弱點)。僅在需要完整文字時才使用 doc/examples/module readme/licenses(LARGE)。
  • 總是傳入 -o md 以便結果以 Markdown(表格,或原始文檔/README)呈現在聊天中。其他格式存在(table 預設、json、raw),但在此處偏好 md。
  • <path> 是完整的導入路徑,例如 github.com/samber/lo — 以位置引數傳入。
  • --version 指定特定的模組版本(v1.5.0、latest、master、main);--module 消除套件所屬模組的歧義。
  • --filter 使用 Go 布林表示式在伺服器端縮減清單結果 — 請參閱篩選語法。
  • --goos/--goarch 設定文檔/符號的建置上下文(例如 linux/amd64)。
  • 當您只需要單一項目的細節時,偏好使用 symbol doc/symbol examples 而非套件範圍的 package doc/package examples。

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-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.

相關技能