Show HN: Codemap – 任意 Go 仓库的单页交互式地图
Show HN: Codemap – one-page interactive map of any Go repository

原始链接: https://github.com/peterretief/codemap

codemap 生成 Go 模块的单个自包含 HTML 地图。它显示每个包、内部依赖关系以及每个文件中的函数,不包括测试。用户可搜索、点击包以检查其使用内容和被谁使用,并对 GitHub 托管的模块直接跳转到函数的源代码行。输出是单个无需服务器的 HTML 文件,适合网站或 CI 构件。在 Go 1.24+ 的模块中运行 `go run github.com/peterretief/codemap@latest -o code-map.html`,或使用 GitHub Action。布局将依赖项放在依赖者下方,为顶层文件夹着色,并按函数数量缩放框宽度。它从名称中省略 `internal/`,并排除 vendor、testdata 和嵌套模块。

Hacker News 展示了一个 Codemap 的 Show HN,这是一个 Go 仓库的一页交互式地图,获得 41 点和 18 条评论。作者说它目前仅支持 Go,但这个想法可以扩展到其他语言。评论者建议了托管版本,将其与 Whiteboard 和 T3 的 Guide 视图进行比较,并讨论了与 ctags 和 Tree-sitter 等工具的验证。一些人希望有供代理使用的 CLI,而另一些人提到 Go 内置的文档和列表工具。反馈包括对有用性的赞扬和对展示效果的批评;作者将其描述为可自由修改的个人导航工具。一位用户还要求在 README 中添加截图。
相关文章

原文

One HTML page that maps a Go module: every package, what it builds on within the module, and the functions in each of its files. Search it, click a package to see what it uses and what uses it, and, for a module on GitHub, jump to any function's line. Tests are left out.

Example: yggstore's map, 40 packages and 1,850 functions.

In your module's folder, with Go 1.24 or later:

go run github.com/peterretief/codemap@latest -o code-map.html

Then open code-map.html in a browser. It's one file with nothing to serve, so it can go on any website. -root DIR maps another folder.

- uses: actions/checkout@v4
- uses: peterretief/[email protected]
  with:
    output: code-map.html
- uses: actions/upload-artifact@v4
  with:
    name: code-map
    path: code-map.html
  • Each row builds only on the rows below it, so the foundations are at the bottom and your commands at the top.
  • Wider boxes have more functions, and colours are top-level folders.
  • internal/ is left off names. vendor, testdata and folders with their own go.mod are left out.
  • The page loads its fonts from Google Fonts, and falls back to system fonts without them.
联系我们 contact @ memedata.com