{"id":13491746,"url":"https://github.com/roblaszczak/go-cleanarch","last_synced_at":"2025-04-04T07:07:42.935Z","repository":{"id":37431332,"uuid":"88099784","full_name":"roblaszczak/go-cleanarch","owner":"roblaszczak","description":"Clean architecture validator for go, like a The Dependency Rule and interaction between packages in your Go projects.","archived":false,"fork":false,"pushed_at":"2021-11-08T16:18:42.000Z","size":816,"stargazers_count":919,"open_issues_count":4,"forks_count":47,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-03-28T06:08:18.741Z","etag":null,"topics":["architecture","clean-architecture","go","golang","uncle-bob"],"latest_commit_sha":null,"homepage":"","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/roblaszczak.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}},"created_at":"2017-04-12T21:59:16.000Z","updated_at":"2025-03-27T23:28:07.000Z","dependencies_parsed_at":"2022-08-19T06:10:56.748Z","dependency_job_id":null,"html_url":"https://github.com/roblaszczak/go-cleanarch","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roblaszczak%2Fgo-cleanarch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roblaszczak%2Fgo-cleanarch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roblaszczak%2Fgo-cleanarch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roblaszczak%2Fgo-cleanarch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/roblaszczak","download_url":"https://codeload.github.com/roblaszczak/go-cleanarch/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247135144,"owners_count":20889421,"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":["architecture","clean-architecture","go","golang","uncle-bob"],"created_at":"2024-07-31T19:00:59.857Z","updated_at":"2025-04-04T07:07:42.919Z","avatar_url":"https://github.com/roblaszczak.png","language":"Go","funding_links":[],"categories":["Architecture Verification (CI Rules / Fitness Functions)","开源类库","Go","Code Analysis","Open source library","Linters","相关工具","代码分析","相关工具`go相关工具和插件`","Libraries for creating HTTP middlewares"],"sub_categories":["Design Patterns","DDD 框架","Routers","DDD Framework","Style and Patterns Checking","代码分析","路由器"],"readme":"# Clean Architecture checker for Golang\n\n[![Go Report Card](https://goreportcard.com/badge/github.com/roblaszczak/go-cleanarch)](https://goreportcard.com/report/github.com/roblaszczak/go-cleanarch)\n\ngo-cleanarch was created to keep Clean Architecture rules,\nlike a _The Dependency Rule_ and _interaction between modules_ in your Go projects.\nFor more information you should read [our article about Clean Architecture](https://threedots.tech/post/introducing-clean-architecture/?utm_source=go-cleanarch).\n\n\nSome benefits of using Clean Architecture:\n\n\u003e 1. Independent of Frameworks. The architecture does not depend on the existence of some library of feature laden software. This allows you to use such frameworks as tools, rather than having to cram your system into their limited constraints.\n\u003e 2. Testable. The business rules can be tested without the UI, Database, Web Server, or any other external element.\n\u003e 3. Independent of UI. The UI can change easily, without changing the rest of the system. A Web UI could be replaced with a console UI, for example, without changing the business rules.\n\u003e 4. Independent of Database. You can swap out Oracle or SQL Server, for Mongo, BigTable, CouchDB, or something else. Your business rules are not bound to the database.\n\u003e 5. Independent of any external agency. In fact your business rules simply don’t know anything at all about the outside world.\n\n_Source: The Clean Architecture_\n\n![Clean Architecture](docs/go-cleanarch.png)\n\n### Project schema requirements\n\ngo-cleanarch assumes this files structure:\n\n    [GOPATH]/[PACKAGE_NAME]/[LAYER_NAME]\n\nor\n\n    [GOPATH]/[PACKAGE_NAME]/[MODULE_NAME]/[LAYER_NAME]\n\nFor example\n\n* go/src/github.com/roblaszczak/awesome-app\n    * auth\n        * domain\n        * application\n        * interfaces\n    * content\n        * domain\n            * submodule1\n            * submodule2\n            * *etc.*\n        * application\n        * interfaces\n    * frontend\n        * domain\n        * application\n        * interfaces\n\n### Allowed `LAYER_NAME`:\n\nThe default layer names are as followed. It is possible to set different names\nby command line parameters see -domain/-application/-interfaces/-infrastructure\nbellow.\n\n    var LayersAliases = map[string]Layer{\n        // Domain\n        \"domain\":   LayerDomain,\n        \"entities\": LayerDomain,\n\n        // Application\n        \"app\":         LayerApplication,\n        \"application\": LayerApplication,\n        \"usecases\":    LayerApplication,\n        \"usecase\":     LayerApplication,\n        \"use_cases\":   LayerApplication,\n\n        // Interfaces\n        \"interfaces\": LayerInterfaces,\n        \"interface\":  LayerInterfaces,\n        \"adapters\":   LayerInterfaces,\n        \"adapter\":    LayerInterfaces,\n\n        // Infrastructure\n        \"infrastructure\": LayerInfrastructure,\n        \"infra\":          LayerInfrastructure,\n    }\n\nFor examples please go to [examples](examples/) directory,\nwith contains examples of valid and invalid architectures.\n\nFor more information you should read [our article about Clean Architecture](https://threedots.tech/post/introducing-clean-architecture/?utm_source=go-cleanarch).\n\n## Installing\n\n    go install github.com/roblaszczak/go-cleanarch@latest\n\n_go-cleanarch was only tested on Linux and also should work on OS X.\nProbably it doesn't work well on Windows._\n\n## Running\n\nTo run in the current directory:\n\n    go-cleanarch\n\nTo run in provided directory\n\n    go-cleanarch go/src/github.com/roblaszczak/awesome-cms\n\nProcess will exit with code `1` if architecture is not valid, otherwise it will exit with `0`.\n\n### -ignore-tests\n\nIf you need to ignore `*_test.go` files in `go-cleanarch` check you can pass `-ignore-tests`\n\n    go-cleanarch -ignore-tests\n\nIt is useful when you have memory implementation in infrastructure layer\nand you need to test application service which depends of it.\n\n### -ignore-package\n\nIf for some reason you need to allow to make forbidden import, for example\n\n`github.com/roblaszczak/go-cleanarch/examples/ignore-package/app` to `github.com/roblaszczak/go-cleanarch/examples/ignore-package/domain`.\n\nyou can use\n\n    go-cleanarch -ignore-package=github.com/roblaszczak/go-cleanarch/examples/ignore-package/app \n\n### Layer names\n\nThe layer names can be set to a specific value with the following parameters. Each\nparameter stands for on layer.\n\n    go-cleanarch -domain dom -application appli -interfaces int -infrastructure outer\n\nThis would only allow the domain name to be dom, application hast to be appli,\ninterafces must be int and infrastructure must be outer.\n\n## Running the tests\n\n    make test\n\n## And coding style tests\n\n    make qa\n\n## Contributing\n\nPlease read [CONTRIBUTING.md](https://gist.github.com/PurpleBooth/b24679402957c63ec426) for details on our code of conduct, and the process for submitting pull requests to us.\n\n## Versioning\n\nWe use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/your/project/tags).\n\n## Credits\n\nMade without love by Robert Laszczak \u003c/3\n\n## License\n\nThis project is licensed under the MIT License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Froblaszczak%2Fgo-cleanarch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Froblaszczak%2Fgo-cleanarch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Froblaszczak%2Fgo-cleanarch/lists"}