golang-pkg-go-dev

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

golang-pkg-go-dev

golang-pkg-go-dev

Dependencies:
godig
go install github.com/samber/godig/cmd/godig@latest
(or use a registered godig MCP server / the hosted instance instead).
godig
queries the pkg.go.dev API. Use it to answer questions about Go packages and modules: docs, symbols, versions, importers and vulnerabilities. It works as a CLI and as an MCP server. All operations are read-only and need no authentication.
依赖:
godig
go install github.com/samber/godig/cmd/godig@latest
(也可使用已注册的godig MCP服务器或托管实例)。
godig
通过查询pkg.go.dev API,可用于解答关于Go包与模块的各类问题:文档、符号、版本、导入者以及漏洞情况。它支持CLI模式与MCP服务器模式,所有操作均为只读且无需认证。

When 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@latest
bash
go install github.com/samber/godig/cmd/godig@latest

Register the MCP server (optional)

注册MCP服务器(可选)

godig mcp
runs over stdio by default, or streamable HTTP with
--transport http
.
stdio (the client launches godig on demand):
bash
claude mcp add pkg-go-dev -- godig mcp
streamable HTTP (shared server at
/mcp
, default
:8080
):
bash
godig mcp --transport http --addr :8080
claude mcp add --transport http pkg-go-dev http://localhost:8080/mcp
Hosted instance (no install needed) — a public server runs at
https://godig.samber.dev/mcp
:
bash
claude mcp add --transport http pkg-go-dev https://godig.samber.dev/mcp
The CLI and the MCP server expose the same operations under matching names. Prefer the CLI when
godig
is installed; the hosted instance is a fallback when it is not.
godig mcp
默认通过标准输入输出(stdio)运行,也可通过
--transport http
启用
流式HTTP
模式。
标准输入输出模式(客户端按需启动godig):
bash
claude mcp add pkg-go-dev -- godig mcp
流式HTTP模式(共享服务器默认监听
:8080
/mcp
路径):
bash
godig mcp --transport http --addr :8080
claude mcp add --transport http pkg-go-dev http://localhost:8080/mcp
托管实例(无需本地安装)——公共服务器地址为
https://godig.samber.dev/mcp
bash
claude mcp add --transport http pkg-go-dev https://godig.samber.dev/mcp
CLI与MCP服务器暴露的操作完全一致。若已安装godig,优先使用CLI;未安装时可使用托管实例作为备选。

Commands

命令说明

Global flags (all commands):
-o/--output table|json|raw|md
(default
table
— pass
-o md
for chat),
--base-url
,
--timeout
,
--log-level debug|info|warn|error|off
. All are also settable via
GODIG_*
env vars.
CommandArgsSpecific flagsPurpose
overview
<path>
--version
Compact summary (metadata, versions, licenses, vulns) — start here
search
<query>
--symbol --limit --filter
Find packages (optionally exporting a symbol)
package info
<path>
--module --version
Package metadata
package imports
<path>
--module --version
Packages this package imports (plain list)
package doc
<path>
--module --version --goos --goarch --format md|text|html|markdown
Full package doc (LARGE)
package examples
<path>
--module --version --goos --goarch --symbol
Runnable examples (LARGE; scope with
--symbol
)
package licenses
<path>
--module --version
License files, full text (LARGE)
symbol doc
<path> <symbol>
--module --version --goos --goarch
One symbol's signature + doc (token-efficient)
symbol examples
<path> <symbol>
--module --version --goos --goarch
One symbol's runnable examples
symbols
<path>
--module --version --goos --goarch --limit --filter
List exported symbols
module info
<path>
--version
Module metadata
module licenses
<path>
--version
Module license files (LARGE)
module readme
<path>
--version
Module README, full Markdown (LARGE)
dependencies
<path>
--version
go.mod deps: requires / replaces / excludes / go directive
packages
<path>
--version --limit --filter
Packages contained in a module
versions
<path>
--limit --filter
All versions, newest first
major-versions
<path>
--limit --filter --exclude-pseudo
Major versions (v1, v2 …) living as separate modules
imported-by
<path>
--module --version --limit --filter
Packages that import this one
vulns
<path>
--module --version --limit --filter
Known vulnerabilities
mcp
--transport stdio|http --addr --cache-ttl --cache-size
Run as an MCP server
version
Print godig version / commit / build date
When
godig
runs as an MCP server, each data command above is exposed as an operation of the same name.
Exit codes:
0
success,
1
runtime error (network, package not found),
2
usage error — a missing/invalid argument or flag (e.g. a non-positive
--limit
), or a command group invoked with no subcommand (
godig package
). Check for
2
to tell a malformed call apart from a failed lookup.
Full
-o md
output for every command: sample-output.md.
全局标志(所有命令通用):
-o/--output table|json|raw|md
(默认值为
table
,在聊天场景中建议使用
-o md
)、
--base-url
--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
完整包文档(内容量大)
package examples
<path>
--module --version --goos --goarch --symbol
可运行示例(内容量大;可通过
--symbol
缩小范围)
package licenses
<path>
--module --version
许可证文件完整内容(内容量大)
symbol doc
<path> <symbol>
--module --version --goos --goarch
单个符号的签名+文档(令牌效率高)
symbol examples
<path> <symbol>
--module --version --goos --goarch
单个符号的可运行示例
symbols
<path>
--module --version --goos --goarch --limit --filter
列出导出的符号
module info
<path>
--version
模块元数据
module licenses
<path>
--version
模块许可证文件(内容量大)
module readme
<path>
--version
模块README完整Markdown内容(内容量大)
dependencies
<path>
--version
go.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>
--module --version --limit --filter
已知漏洞
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

Tips

使用技巧

  • Start with
    overview
    — one call returns a compact summary (metadata, latest + recent versions, license types, vulnerabilities). Reach for
    doc
    /
    examples
    /
    module readme
    /
    licenses
    (LARGE) only when the full text is needed.
  • Always pass
    -o md
    so results render as Markdown (tables, or raw doc/README) in the chat. Other formats exist (
    table
    default,
    json
    ,
    raw
    ) but prefer
    md
    here.
  • <path>
    is a full import path, e.g.
    github.com/samber/lo
    — pass it as the positional argument.
  • --version
    pins a specific module version (
    v1.5.0
    ,
    latest
    ,
    master
    ,
    main
    );
    --module
    disambiguates which module a package belongs to.
  • --filter
    narrows list results server-side with a Go boolean expression — see Filter syntax.
  • --goos
    /
    --goarch
    set the documentation/symbols build context (e.g.
    linux
    /
    amd64
    ).
  • Prefer
    symbol doc
    /
    symbol examples
    over the package-wide
    package doc
    /
    package examples
    when you only need one symbol — far fewer tokens.
  • 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
    godig
    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
    godig
    calls and returning a compact summary, so the raw LARGE output never lands in the main context.
  • Listing commands auto-paginate (return all results); use
    --limit
    to cap.
  • overview
    开始
    ——一次调用即可返回简洁概览(元数据、最新及近期版本、许可证类型、漏洞)。仅当需要完整内容时,再使用
    doc
    /
    examples
    /
    module readme
    /
    licenses
    (内容量大)。
  • 始终添加
    -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
    ——所需令牌数少得多。
  • 并行执行独立查询——每个命令都是独立的只读HTTP查询,调用之间互不依赖。当任务需要查询多个符号、包或模块的文档、示例、版本或漏洞时,应同时发起所有调用(在一个回合中多次调用
    godig
    ),而非依次调用——这样总耗时会从各调用延迟之和变为最慢单次调用的延迟。对于大规模查询(例如为多个符号编写文档、比较多个候选库、审计依赖集的CVE漏洞),可通过Agent工具调度并行子代理(最多5个),每个子代理运行各自的
    godig
    调用并返回简洁概览,避免大量原始内容进入主上下文。
  • 列表类命令会自动分页(返回所有结果);可使用
    --limit
    限制返回数量。

Filter syntax

过滤语法

--filter
(on
search
,
versions
,
major-versions
,
packages
,
imported-by
,
symbols
,
vulns
) takes a Go boolean expression evaluated server-side, once per result item. It is not a regex — wrap the whole expression in single quotes for the shell.
  • Identifiers are the item's fields, which differ per command — a field valid for one list is rejected by another (e.g.
    search
    exposes
    packagePath
    , not
    path
    ). An unknown field fails with
    undefined identifier: <name>
    (HTTP 400), which names the offending field. Casing is not uniform: most fields use the lowercase JSON key, but
    vulns
    uses Go-style names (
    ID
    , not
    id
    ), and
    kind
    values are capitalized (
    Function
    , not
    func
    ).
  • Operators:
    ==
    !=
    <
    <=
    >
    >=
    , boolean
    &&
    ||
    !
    , parentheses for grouping.
  • String functions:
    contains(s, sub)
    ,
    hasPrefix(s, pre)
    ,
    hasSuffix(s, suf)
    .
  • Literals: double-quoted strings (
    "Function"
    ),
    true
    /
    false
    , numbers.
Filterable fields per command (string unless noted):
CommandFields
search
modulePath
,
packagePath
,
synopsis
,
version
versions
version
,
modulePath
,
deprecated
(bool),
retracted
(bool),
hasGoMod
(bool),
commitTime
packages
path
,
name
,
synopsis
,
isRedistributable
(bool)
imported-by
path
(the importing package path)
symbols
name
,
kind
(
Function
/
Method
/
Type
/
Variable
/
Constant
),
synopsis
,
parent
vulns
ID
,
package
,
Details
major-versions
modulePath
,
major
,
version
,
isLatest
(bool)
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
--filter
适用于
search
versions
major-versions
packages
imported-by
symbols
vulns
命令,接收一个在服务端针对每个结果项执行的Go布尔表达式。它不是正则表达式——需用单引号将整个表达式包裹以适配shell。
  • 标识符为结果项的字段,不同命令的字段不同——某命令可用的字段在其他命令中可能无效(例如
    search
    暴露
    packagePath
    而非
    path
    )。未知字段会导致
    undefined identifier: <name>
    错误(HTTP 400),并指出错误字段。字段大小写不统一:大多数字段使用小写JSON键,但
    vulns
    使用Go风格命名(
    ID
    而非
    id
    ),
    kind
    值为首字母大写(
    Function
    而非
    func
    )。
  • 运算符
    ==
    !=
    <
    <=
    >
    >=
    ,布尔运算符
    &&
    ||
    !
    ,括号用于分组。
  • 字符串函数
    contains(s, sub)
    hasPrefix(s, pre)
    hasSuffix(s, suf)
  • 字面量:双引号字符串(
    "Function"
    )、
    true
    /
    false
    、数字。
各命令可过滤的字段(除非注明,均为字符串类型):
命令字段
search
modulePath
,
packagePath
,
synopsis
,
version
versions
version
,
modulePath
,
deprecated
(布尔型),
retracted
(布尔型),
hasGoMod
(布尔型),
commitTime
packages
path
,
name
,
synopsis
,
isRedistributable
(布尔型)
imported-by
path
(导入当前包的包路径)
symbols
name
,
kind
Function
/
Method
/
Type
/
Variable
/
Constant
),
synopsis
,
parent
vulns
ID
,
package
,
Details
major-versions
modulePath
,
major
,
version
,
isLatest
(布尔型)
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

Examples

使用示例

Always request Markdown output (
-o md
):
bash
undefined
始终请求Markdown输出(
-o md
):
bash
undefined

Overview — 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>提交问题。