goimportcycle icon indicating copy to clipboard operation
goimportcycle copied to clipboard

Tooling for Go import cycles

Go Import Cycle

Go Report Card

goimportcycle is a tool to visualize Go imports resolved to the package or file level.

Installation

go get -u github.com/samlitowitz/goimportcycle/cmd/goimportcycle

Usage

goimportcycle -path examples/importcycle/ -dot imports.dot
dot -Tpng -o assets/example.png imports.dot

Example import graph resolved to the file level

Red lines indicate files causing import cycles between packages. Packages involved in a cycle have their backgrounds colored red.

goimportcycle -path examples/importcycle/ -dot imports.dot -resolution package
dot -Tpng -o assets/example.png imports.dot

Example import graph resolved to the package level

Red lines indicate import cycles between packages.

Tasks that probably should get done

  1. Make output graphs nicely organized (vague)