Loading page...Загружаем страницу...正在加载页面...
AtlasRepo

Finding cycles and hidden dependencies in go mod graph

说明与用途

使用 gograph 对 Go 模块依赖图进行自动化分析,可快速识别循环和依赖模块。

问题

Analyzing a large Go module dependency graph to identify cycles, dependents, and hidden dependencies is difficult with raw go mod graph output.

结果

Cycles are detected quickly (≈10 ms on a laptop) and dependents are listed for any module. The approach scales to large graphs and replaces manual grep with automated graph traversal.

工作流

  • Run go mod graph | go run github.com/hmdsefi/gograph/examples/gomodgraph@latest cycles to find cycles.
  • Run go run github.com/hmdsefi/gograph/examples/gomodgraph@latest dependents <module> to list dependents.
  • Use gomodgraph -f graph.txt cycles or dependents with a file for larger graphs.
  • Optionally use gograph.dev for interactive exploration of small graphs.

证据

go mod graph prints every requirement in your module graph, one per line.

来源

I loaded it into gograph, the graph library I maintain, and wrote a small program, gomodgraph, that answers those questions.

来源

On Prometheus it finds one cycle: go.opentelemetry.io/otel/[email protected] go.opentelemetry.io/otel/[email protected] go.opentelemetry.io/[email protected]

来源

  • 记录日期: 2026-10-12T18:41:30.582Z