{"id":27916805,"url":"https://github.com/mickamy/goimportmaps","last_synced_at":"2025-05-06T16:41:19.014Z","repository":{"id":289953109,"uuid":"972930227","full_name":"mickamy/goimportmaps","owner":"mickamy","description":"Visualize and validate package dependencies in your Go project","archived":false,"fork":false,"pushed_at":"2025-04-25T23:27:40.000Z","size":547,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-26T00:19:43.777Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mickamy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-04-25T23:11:03.000Z","updated_at":"2025-04-26T00:16:57.000Z","dependencies_parsed_at":"2025-04-26T00:32:20.294Z","dependency_job_id":null,"html_url":"https://github.com/mickamy/goimportmaps","commit_stats":null,"previous_names":["mickamy/goimportmaps"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mickamy%2Fgoimportmaps","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mickamy%2Fgoimportmaps/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mickamy%2Fgoimportmaps/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mickamy%2Fgoimportmaps/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mickamy","download_url":"https://codeload.github.com/mickamy/goimportmaps/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252722225,"owners_count":21794002,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-05-06T16:41:15.131Z","updated_at":"2025-05-06T16:41:19.009Z","avatar_url":"https://github.com/mickamy.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# goimportmaps\n\n\u003e Visualize and validate package dependencies in your Go project.\n\u003e\n\n![Screenshot](./assets/html_report.png)\n\n## Overview\n\n`goimportmaps` is a CLI tool that analyzes your Go project's internal package imports, visualizes them as a dependency\ngraph, and detects architectural violations like forbidden dependencies or unexpected imports.\n\nIdeal for large-scale or monorepo Go applications, this tool helps ensure architectural integrity by preventing\nundesired package-level coupling.\n\n## Features\n\n- 📊 Visualize internal package dependencies (Mermaid, Graphviz, HTML)\n- 🚨 Detect forbidden imports based on custom rules (`forbidden` mode)\n- 🛡 Enforce allowed imports strictly (`allowed` mode, whitelist style)\n- ✅ Output violations with actionable messages\n- 🔍 Highlight architectural drift in pull requests\n- 🧠 Perfect for layered, hexagonal, or clean architecture\n\n## Installation\n\n```bash\n# Install goimportmaps into your project\ngo get -tool github.com/mickamy/goimportmaps/cmd/goimportmaps@latest\n\n# or install it globally\ngo install github.com/mickamy/goimportmaps/cmd/goimportmaps@latest\n```\n\n## Usage\n\n```bash\ngoimportmaps ./...\n```\n\nYou can also scope the analysis to specific subdirectories:\n\n```bash\ngoimportmaps ./internal/...\n```\n\n### Options\n\n| Option     | Description                                             |\n|------------|---------------------------------------------------------|\n| `--format` | Output format: `text`, `mermaid`, `html`, or `graphviz` |\n| `--mode`   | Validation mode: `forbidden` (default) or `allowed`     |\n\n## Example\n\nGiven the following structure:\n\n```\nmain\n├── handler\n│   └── user_handler.go (imports service)\n├── service\n│   └── user_service.go (imports infra)\n└── infra\n    └── db.go\n```\n\n### Forbidden Mode (default)\n\nIf `handler` imports `infra` directly, the tool will detect:\n\n```bash\n🚨 1 violation(s) found\n\n🚨 Violation: github.com/your/project/internal/handler imports github.com/your/project/internal/infra\n```\n\n### Allowed Mode (strict whitelist)\n\nYou can enforce exact allowed imports:\n\n```yaml\nallowed:\n  - source: github.com/your/project/internal/handler\n    imports:\n      - github.com/your/project/internal/service\n    stdlib: true # allow importing standard library packages as well (default: true)\n```\n\nIf `handler` tries to import anything other than `service` or stdlib (e.g., `infra`), it will be flagged.\n\n---\n\n### Mermaid Output Example\n\n```markdown\ngraph TD\n  main --\u003e handler\n  handler --\u003e service\n  service --\u003e infra\n  handler --\u003e infra %% ❌\n```\n\n---\n\n## Configuration\n\n`.goimportmaps.yaml`\n\n### Forbidden Mode Example\n\n```yaml\nforbidden:\n  - source: github.com/your/project/internal/handler\n    imports:\n      - github.com/your/project/internal/infra\n  - source: github.com/your/project/internal/app\n    imports:\n      - github.com/your/project/internal/db\n```\n\n### Allowed Mode Example\n\n```yaml\nallowed:\n  - source: github.com/your/project/internal/handler\n    imports:\n      - github.com/your/project/internal/service\n  - source: github.com/your/project/internal/service\n    imports:\n      - github.com/your/project/internal/repository\n    stdlib: false\n```\n\n## HTML Output\n\nUse `--format=html` to generate a standalone static report:\n\n```bash\ngoimportmaps ./... --format=html \u003e report.html\n\n```\n\nThis report can be viewed in your browser or uploaded as a CI artifact.\n\n## License\n\n[MIT](./LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmickamy%2Fgoimportmaps","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmickamy%2Fgoimportmaps","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmickamy%2Fgoimportmaps/lists"}