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

Finding cycles and hidden dependencies in go mod graph

Description and use

Automated analysis of a Go module dependency graph using gograph quickly identifies cycles and dependents.

Problem

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

Outcome

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.

Workflow

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

Evidence

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

Source

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

Source

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

Source

  • Record date: 2026-10-12T18:41:30.582Z