imports
is a CLI tool that generates a dependency graph of the internal imports of a Go project.
- Graphviz
- Debian:
apt install graphviz
- macOS:
brew install graphviz
- Debian:
git clone https://github.com/benbjohnson/litestream.git
cd litestream
go mod download
go run github.com/xpetit/imports@latest ./cmd/litestream > litestream.gv
dot -O -Tsvg litestream.gv
The resulting file litestream.gv.svg :
You can limit the depth for projects with bigger import graphs:
git clone https://github.com/caddyserver/caddy.git
cd caddy
go mod download
go run github.com/xpetit/imports@latest -depth 2 ./cmd/caddy > caddy.gv
dot -O -Tsvg caddy.gv
The resulting file caddy.gv.svg :