golang-pkg-go-dev
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinesegolang-pkg-go-dev
golang-pkg-go-dev
Dependencies: — (or use a registered godig MCP server / the hosted instance instead).
godiggo install github.com/samber/godig/cmd/godig@latestgodig依赖: — (也可使用已注册的godig MCP服务器或托管实例)。
godiggo install github.com/samber/godig/cmd/godig@latestgodigWhen to use this skill
适用场景
Trigger on questions like:
- "What versions of github.com/samber/lo are available?"
- "Does golang.org/x/text have known vulnerabilities?"
- "Show me the docs / symbols for package X."
- "Which packages import X?"
- "Search Go packages for Y."
适用于以下类型的问题:
- "github.com/samber/lo有哪些可用版本?"
- "golang.org/x/text是否存在已知漏洞?"
- "展示包X的文档/符号。"
- "哪些包导入了X?"
- "搜索包含Y功能的Go包。"
Setup
安装配置
Install
安装
bash
go install github.com/samber/godig/cmd/godig@latestbash
go install github.com/samber/godig/cmd/godig@latestRegister the MCP server (optional)
注册MCP服务器(可选)
godig mcp--transport httpstdio (the client launches godig on demand):
bash
claude mcp add pkg-go-dev -- godig mcpstreamable HTTP (shared server at , default ):
/mcp:8080bash
godig mcp --transport http --addr :8080
claude mcp add --transport http pkg-go-dev http://localhost:8080/mcpHosted instance (no install needed) — a public server runs at :
https://godig.samber.dev/mcpbash
claude mcp add --transport http pkg-go-dev https://godig.samber.dev/mcpThe CLI and the MCP server expose the same operations under matching names. Prefer the CLI when is installed; the hosted instance is a fallback when it is not.
godiggodig mcp--transport http标准输入输出模式(客户端按需启动godig):
bash
claude mcp add pkg-go-dev -- godig mcp流式HTTP模式(共享服务器默认监听的路径):
:8080/mcpbash
godig mcp --transport http --addr :8080
claude mcp add --transport http pkg-go-dev http://localhost:8080/mcp托管实例(无需本地安装)——公共服务器地址为:
https://godig.samber.dev/mcpbash
claude mcp add --transport http pkg-go-dev https://godig.samber.dev/mcpCLI与MCP服务器暴露的操作完全一致。若已安装godig,优先使用CLI;未安装时可使用托管实例作为备选。
Commands
命令说明
Global flags (all commands): (default — pass for chat), , , . All are also settable via env vars.
-o/--output table|json|raw|mdtable-o md--base-url--timeout--log-level debug|info|warn|error|offGODIG_*| Command | Args | Specific flags | Purpose |
|---|---|---|---|
| | | Compact summary (metadata, versions, licenses, vulns) — start here |
| | | Find packages (optionally exporting a symbol) |
| | | Package metadata |
| | | Packages this package imports (plain list) |
| | | Full package doc (LARGE) |
| | | Runnable examples (LARGE; scope with |
| | | License files, full text (LARGE) |
| | | One symbol's signature + doc (token-efficient) |
| | | One symbol's runnable examples |
| | | List exported symbols |
| | | Module metadata |
| | | Module license files (LARGE) |
| | | Module README, full Markdown (LARGE) |
| | | go.mod deps: requires / replaces / excludes / go directive |
| | | Packages contained in a module |
| | | All versions, newest first |
| | | Major versions (v1, v2 …) living as separate modules |
| | | Packages that import this one |
| | | Known vulnerabilities |
| — | | Run as an MCP server |
| — | — | Print godig version / commit / build date |
When runs as an MCP server, each data command above is exposed as an operation of the same name.
godigExit codes: success, runtime error (network, package not found), usage error — a missing/invalid argument or flag (e.g. a non-positive ), or a command group invoked with no subcommand (). Check for to tell a malformed call apart from a failed lookup.
012--limitgodig package2Full output for every command: sample-output.md.
-o md全局标志(所有命令通用): (默认值为,在聊天场景中建议使用)、、、。所有标志也可通过环境变量设置。
-o/--output table|json|raw|mdtable-o md--base-url--timeout--log-level debug|info|warn|error|offGODIG_*| 命令 | 参数 | 专属标志 | 用途 |
|---|---|---|---|
| | | 简洁概览(元数据、版本、许可证、漏洞)——建议从该命令开始 |
| | | 查找包(可筛选导出特定符号的包) |
| | | 包元数据 |
| | | 当前包导入的包(纯列表) |
| | | 完整包文档(内容量大) |
| | | 可运行示例(内容量大;可通过 |
| | | 许可证文件完整内容(内容量大) |
| | | 单个符号的签名+文档(令牌效率高) |
| | | 单个符号的可运行示例 |
| | | 列出导出的符号 |
| | | 模块元数据 |
| | | 模块许可证文件(内容量大) |
| | | 模块README完整Markdown内容(内容量大) |
| | | go.mod依赖信息:requires/replaces/excludes/go指令 |
| | | 模块包含的所有包 |
| | | 所有版本(按从新到旧排序) |
| | | 主版本(v1、v2…),以独立模块形式存在 |
| | | 导入当前包的所有包 |
| | | 已知漏洞 |
| — | | 以MCP服务器模式运行 |
| — | — | 打印godig版本/提交记录/构建日期 |
当godig以MCP服务器模式运行时,上述每个数据命令都会以同名操作暴露。
退出码: 表示成功,表示运行时错误(网络问题、包未找到),表示用法错误——缺少/无效参数或标志(例如为非正数),或未指定子命令的命令组调用(如)。可通过退出码区分格式错误的调用与查询失败的情况。
012--limitgodig package2所有命令的完整输出示例:sample-output.md。
-o mdTips
使用技巧
- Start with — one call returns a compact summary (metadata, latest + recent versions, license types, vulnerabilities). Reach for
overview/doc/examples/module readme(LARGE) only when the full text is needed.licenses - Always pass so results render as Markdown (tables, or raw doc/README) in the chat. Other formats exist (
-o mddefault,table,json) but preferrawhere.md - is a full import path, e.g.
<path>— pass it as the positional argument.github.com/samber/lo - pins a specific module version (
--version,v1.5.0,latest,master);maindisambiguates which module a package belongs to.--module - narrows list results server-side with a Go boolean expression — see Filter syntax.
--filter - /
--goosset the documentation/symbols build context (e.g.--goarch/linux).amd64 - Prefer /
symbol docover the package-widesymbol examples/package docwhen you only need one symbol — far fewer tokens.package examples - Parallelize independent lookups — every command is a self-contained, read-only HTTP query, so calls never depend on each other. When a task needs docs, examples, versions, or vulns for several symbols, packages, or modules, issue all the calls at once (multiple invocations in a single turn) rather than one after another — wall-clock drops from sum-of-latencies to slowest-single-call. For a large fan-out (documenting many symbols, comparing many candidate libraries, auditing CVEs across a dependency set), dispatch parallel sub-agents (up to 5) via the Agent tool, each running its own
godigcalls and returning a compact summary, so the raw LARGE output never lands in the main context.godig - Listing commands auto-paginate (return all results); use to cap.
--limit
- 从开始——一次调用即可返回简洁概览(元数据、最新及近期版本、许可证类型、漏洞)。仅当需要完整内容时,再使用
overview/doc/examples/module readme(内容量大)。licenses - 始终添加——让结果以Markdown格式(表格或原始文档/README)在聊天中渲染。其他格式(默认
-o md、table、json)也存在,但聊天场景中优先使用raw。md - 为完整导入路径,例如
<path>——需作为位置参数传入。github.com/samber/lo - 用于指定特定模块版本(
--version、v1.5.0、latest、master);main用于明确包所属的模块。--module - 通过Go布尔表达式在服务端缩小列表结果范围——详见过滤语法。
--filter - /
--goos用于设置文档/符号的构建上下文(例如--goarch/linux)。amd64 - 若仅需单个符号的信息,优先使用/
symbol doc而非包级别的symbol examples/package doc——所需令牌数少得多。package examples - 并行执行独立查询——每个命令都是独立的只读HTTP查询,调用之间互不依赖。当任务需要查询多个符号、包或模块的文档、示例、版本或漏洞时,应同时发起所有调用(在一个回合中多次调用),而非依次调用——这样总耗时会从各调用延迟之和变为最慢单次调用的延迟。对于大规模查询(例如为多个符号编写文档、比较多个候选库、审计依赖集的CVE漏洞),可通过Agent工具调度并行子代理(最多5个),每个子代理运行各自的
godig调用并返回简洁概览,避免大量原始内容进入主上下文。godig - 列表类命令会自动分页(返回所有结果);可使用限制返回数量。
--limit
Filter syntax
过滤语法
--filtersearchversionsmajor-versionspackagesimported-bysymbolsvulns- Identifiers are the item's fields, which differ per command — a field valid for one list is rejected by another (e.g. exposes
search, notpackagePath). An unknown field fails withpath(HTTP 400), which names the offending field. Casing is not uniform: most fields use the lowercase JSON key, butundefined identifier: <name>uses Go-style names (vulns, notID), andidvalues are capitalized (kind, notFunction).func - Operators:
==!=<<=>, boolean>=&&||, parentheses for grouping.! - String functions: ,
contains(s, sub),hasPrefix(s, pre).hasSuffix(s, suf) - Literals: double-quoted strings (),
"Function"/true, numbers.false
Filterable fields per command (string unless noted):
| Command | Fields |
|---|---|
| |
| |
| |
| |
| |
| |
| |
bash
godig symbols github.com/samber/lo --filter 'kind=="Function"' -o md
godig symbols github.com/samber/lo --filter 'kind=="Function" && hasPrefix(name,"Map")' -o md
godig versions github.com/samber/lo --filter 'hasPrefix(version,"v1.5")' -o md
godig versions github.com/samber/lo --filter 'deprecated==false && retracted==false' -o md
godig search "result option" --filter 'hasPrefix(packagePath,"github.com/samber/")' -o md--filtersearchversionsmajor-versionspackagesimported-bysymbolsvulns- 标识符为结果项的字段,不同命令的字段不同——某命令可用的字段在其他命令中可能无效(例如暴露
search而非packagePath)。未知字段会导致path错误(HTTP 400),并指出错误字段。字段大小写不统一:大多数字段使用小写JSON键,但undefined identifier: <name>使用Go风格命名(vulns而非ID),id值为首字母大写(kind而非Function)。func - 运算符:
==!=<<=>,布尔运算符>=&&||,括号用于分组。! - 字符串函数:、
contains(s, sub)、hasPrefix(s, pre)。hasSuffix(s, suf) - 字面量:双引号字符串()、
"Function"/true、数字。false
各命令可过滤的字段(除非注明,均为字符串类型):
| 命令 | 字段 |
|---|---|
| |
| |
| |
| |
| |
| |
| |
bash
godig symbols github.com/samber/lo --filter 'kind=="Function"' -o md
godig symbols github.com/samber/lo --filter 'kind=="Function" && hasPrefix(name,"Map")' -o md
godig versions github.com/samber/lo --filter 'hasPrefix(version,"v1.5")' -o md
godig versions github.com/samber/lo --filter 'deprecated==false && retracted==false' -o md
godig search "result option" --filter 'hasPrefix(packagePath,"github.com/samber/")' -o mdExamples
使用示例
Always request Markdown output ():
-o mdbash
undefined始终请求Markdown输出():
-o mdbash
undefinedOverview — start here (compact, one call)
概览——从该命令开始(简洁,单次调用)
godig overview github.com/samber/ro -o md
godig overview github.com/samber/ro -o md
Search
搜索
godig search "result option monad" --limit 5 -o md
godig search "result option monad" --limit 5 -o md
Package facets
包相关信息
godig package info github.com/samber/ro -o md
godig package imports github.com/samber/ro -o md
godig package doc github.com/samber/ro --format md -o md
godig package examples github.com/samber/ro --symbol Map -o md
godig package licenses github.com/samber/ro -o md
godig package info github.com/samber/ro -o md
godig package imports github.com/samber/ro -o md
godig package doc github.com/samber/ro --format md -o md
godig package examples github.com/samber/ro --symbol Map -o md
godig package licenses github.com/samber/ro -o md
Single symbol (token-efficient vs package-wide doc/examples)
单个符号信息(相比包级文档/示例,令牌效率更高)
godig symbol doc github.com/samber/lo Map -o md
godig symbol examples github.com/samber/oops OopsError.Error -o md
godig symbol doc github.com/samber/lo Map -o md
godig symbol examples github.com/samber/oops OopsError.Error -o md
Module facets
模块相关信息
godig module info github.com/samber/ro -o md
godig module readme github.com/samber/ro -o raw
godig dependencies github.com/samber/ro -o md
godig module info github.com/samber/ro -o md
godig module readme github.com/samber/ro -o raw
godig dependencies github.com/samber/ro -o md
Lists (auto-paginated; --limit to cap)
列表类命令(自动分页;可通过--limit限制数量)
godig versions github.com/samber/ro -o md
godig major-versions github.com/samber/lo -o md
godig packages github.com/samber/ro -o md
godig imported-by github.com/samber/ro --limit 20 -o md
godig symbols github.com/samber/ro --filter 'kind=="Function"' -o md
godig versions github.com/samber/ro -o md
godig major-versions github.com/samber/lo -o md
godig packages github.com/samber/ro -o md
godig imported-by github.com/samber/ro --limit 20 -o md
godig symbols github.com/samber/ro --filter 'kind=="Function"' -o md
Pin a version / set the build context
指定版本/设置构建上下文
godig versions github.com/samber/ro --filter 'hasPrefix(version,"v0.3")' -o md
godig package doc github.com/samber/lo --version v1.50.0 -o md
godig symbols github.com/samber/ro --goos linux --goarch amd64 -o md
godig versions github.com/samber/ro --filter 'hasPrefix(version,"v0.3")' -o md
godig package doc github.com/samber/lo --version v1.50.0 -o md
godig symbols github.com/samber/ro --goos linux --goarch amd64 -o md
Vulnerabilities
漏洞查询
godig vulns github.com/samber/ro -o md
---
This skill is not exhaustive. `godig --help` and each sub-command's `--help` list current flags and output formats; the data mirrors what [pkg.go.dev](https://pkg.go.dev) exposes.
If you encounter a bug or unexpected behavior in `godig`, open an issue at <https://github.com/samber/godig/issues>.godig vulns github.com/samber/ro -o md
---
本技能并非涵盖所有场景。`godig --help`及各子命令的`--help`会列出当前支持的标志与输出格式;数据与[pkg.go.dev](https://pkg.go.dev)展示的内容一致。
若在使用`godig`时遇到Bug或异常行为,请在<https://github.com/samber/godig/issues>提交问题。