https://github.com/samlitowitz/goimportcycle
Tooling for Go import cycles
https://github.com/samlitowitz/goimportcycle
Last synced: 3 months ago
JSON representation
Tooling for Go import cycles
- Host: GitHub
- URL: https://github.com/samlitowitz/goimportcycle
- Owner: samlitowitz
- License: apache-2.0
- Created: 2022-01-02T06:01:10.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2024-07-25T03:27:59.000Z (12 months ago)
- Last Synced: 2024-08-02T20:45:45.267Z (11 months ago)
- Language: Go
- Size: 977 KB
- Stars: 66
- Watchers: 3
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.markdown
- License: LICENSE
Awesome Lists containing this project
README
# Go Import Cycle
[](https://goreportcard.com/report/github.com/samlitowitz/goimportcycle)`goimportcycle` is a tool to visualize Go imports resolved to the package or file level.
# Installation
`go install github.com/samlitowitz/goimportcycle/cmd/[email protected]`# Usage
```shell
goimportcycle -path examples/simple/ -dot imports.dot
dot -Tpng -o assets/example.png imports.dot
```
Red lines indicate files causing import cycles between packages. Packages involved in a cycle have their backgrounds colored red.
```shell
goimportcycle -path examples/simple/ -dot imports.dot -resolution package
dot -Tpng -o assets/example.png imports.dot
```
Red lines indicate import cycles between packages.
## Configuration
The configuration file follows the JSON Schema outlined in [assets/config-schema](assets/config-schema).The [simple-config example](examples/simple-config) uses the following schema...
```yaml
palette:
base:
packageName: "rgb(174, 209, 230)"
packageBackground: "rgb(207, 232, 239)"
fileName: "rgb(160, 196, 226)"
fileBackground: "rgb(198, 219, 240)"
importArrow: "rgb(133, 199, 222)"
cycle:
packageName: "#FFB3C6"
packageBackground: "#FFE5EC"
fileName: "#FF8FAB"
fileBackground: "#FFC2D1"
importArrow: "#FB6F92"
```...to produce the following outputs...

