{"id":17135772,"url":"https://github.com/arch-go/arch-go","last_synced_at":"2026-01-14T21:07:51.076Z","repository":{"id":43704156,"uuid":"351282380","full_name":"arch-go/arch-go","owner":"arch-go","description":"Architecture checks for Go projects","archived":false,"fork":false,"pushed_at":"2026-01-12T21:51:56.000Z","size":1498,"stargazers_count":241,"open_issues_count":16,"forks_count":17,"subscribers_count":4,"default_branch":"main","last_synced_at":"2026-01-13T01:57:04.005Z","etag":null,"topics":["architecture","go","golang","quality","testing","testing-automation","testing-tools","tools"],"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/arch-go.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":"MAINTAINERS.md","copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2021-03-25T02:14:45.000Z","updated_at":"2026-01-11T11:51:47.000Z","dependencies_parsed_at":"2024-06-13T06:18:12.478Z","dependency_job_id":"677532b4-1dd3-4e80-ab2f-5f50cd543390","html_url":"https://github.com/arch-go/arch-go","commit_stats":null,"previous_names":["arch-go/arch-go","fdaines/arch-go"],"tags_count":77,"template":false,"template_full_name":null,"purl":"pkg:github/arch-go/arch-go","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arch-go%2Farch-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arch-go%2Farch-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arch-go%2Farch-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arch-go%2Farch-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/arch-go","download_url":"https://codeload.github.com/arch-go/arch-go/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arch-go%2Farch-go/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28434557,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T18:57:19.464Z","status":"ssl_error","status_checked_at":"2026-01-14T18:52:48.501Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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","go","golang","quality","testing","testing-automation","testing-tools","tools"],"created_at":"2024-10-14T20:01:01.458Z","updated_at":"2026-01-14T21:07:51.063Z","avatar_url":"https://github.com/arch-go.png","language":"Go","funding_links":[],"categories":["Architecture Verification (CI Rules / Fitness Functions)","Testing","Template Engines","测试","Go"],"sub_categories":["Design Patterns","Testing Frameworks"],"readme":"\n[![CI](https://github.com/arch-go/arch-go/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/arch-go/arch-go/actions/workflows/ci.yml)\n[![Codecov](https://codecov.io/gh/arch-go/arch-go/branch/main/graph/badge.svg)](https://codecov.io/gh/arch-go/arch-go)\n[![Go Reference](https://pkg.go.dev/badge/github.com/arch-go/arch-go.svg)](https://pkg.go.dev/github.com/arch-go/arch-go)\n[![Go Report Card](https://goreportcard.com/badge/github.com/arch-go/arch-go)](https://goreportcard.com/report/github.com/arch-go/arch-go)\n\u003cimg align=\"center\" src=\"logo.png\" alt=\"Arch-Go\" title=\"Arch-Go\" width=\"600px\"/\u003e\n\n# Arch-Go\nArchitecture checks for Go projects\n\n# Supported rules\n\n## Dependencies Checks\nSupports defining import rules\n- Allowed dependencies\n  - internal dependencies (same module)\n  - standard library dependencies\n  - external dependencies (3rd party packages)\n- Not allowed dependencies\n    - internal dependencies (same module)\n    - standard library dependencies\n    - external dependencies (3rd party packages)\n  \n## Package Content Checks\nAllows you to define the contents of a set of packages, e.g. you can define that a desired package should only contain interfaces definitions.\nThe supported checks are:\n* shouldNotContainInterfaces\n* shouldNotContainStructs\n* shouldNotContainFunctions\n* shouldNotContainMethods\n* shouldOnlyContainInterfaces\n* shouldOnlyContainStructs\n* shouldOnlyContainFunctions\n* shouldOnlyContainMethods\n\n## Function checks\nChecks some functions properties, like the following:\n- Maximum number of parameters\n- Maximum number of return values\n- Maximum number of public functions per file\n- Maximum number of lines in the function body\n\n## Naming rules checks\nChecks some naming rules, like the following:\n- If a struct implements an interface that match some name pattern, then it's name should starts or ends with a specific pattern. For example, all structs that implements 'Verificator' interface, should have a name that ends with 'Verificator'\n  \n# Configuration\n\n## File arch-go.yml\n```yaml\nversion: 1\nthreshold:\n  compliance: 100\n  coverage: 100\ndependenciesRules:\n  - package: \"**.impl.*\"\n    shouldOnlyDependsOn:\n      internal:\n          - \"**.foo.*\"\n          - \"*.bar.*\"\n    shouldNotDependsOn: \n      internal: [\"**.model.**\"]\n  - package: \"**.utils.**\"\n    shouldOnlyDependsOn:\n      - \"**.model.**\"\n  - package: \"**.foobar.**\"\n    shouldOnlyDependsOn:\n      external:\n        - \"gopkg.in/yaml.v3\"\n  - package: \"**.example.**\"\n    shouldNotDependsOn:\n      external:\n        - \"github.com/foobar/example-module\"\ncontentsRules:\n  - package: \"**.impl.model\"\n    shouldNotContainInterfaces: true\n  - package: \"**.impl.configuration\"\n    shouldOnlyContainFunctions: true\n  - package: \"**.impl.dependencies\"\n    shouldNotContainStructs: true\n    shouldNotContainInterfaces: true\n    shouldNotContainMethods: true\n    shouldNotContainFunctions: true\nfunctionsRules:\n  - package: \"**.impl.**\"\n    maxParameters: 3\n    maxReturnValues: 2\n    maxPublicFunctionPerFile: 1\n    maxLines: 50\nnamingRules:\n  - package: \"**.arch-go.**\"\n    interfaceImplementationNamingRule:\n      structsThatImplement: \n        internal: \"*Connection\"\n      shouldHaveSimpleNameEndingWith: \"Connection\"\n  - package: \"**.impl.**\"\n    interfaceImplementationNamingRule:\n      structsThatImplement:\n        external:\n          package: \"github.com/some/package\"\n          interface: \"SomeInterface\"\n      shouldHaveSimpleNameEndingWith: \"SomeName\"\n  - package: \"**.impl.**\"\n    interfaceImplementationNamingRule:\n      structsThatImplement:\n        standard:\n          package: \"builtin\"\n          interface: \"error\"\n      shouldHaveSimpleNameEndingWith: \"Err\"\n  - package: \"**.impl.**\"\n    interfaceImplementationNamingRule:\n      structsThatImplement:\n        standard:\n          package: \"io\"\n          interface: \"Writer\"\n      shouldHaveSimpleNameEndingWith: \"Writer\"\n```\n\n## Package name patterns\nThe package name can be defined as a fixed value or using _*_ special character, to create a simple pattern.\n\n| Example         | Description                                                                                                                                                          |\n|-----------------|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| *.name          | Package should end with _name_ and anything before, supporting only one level (for example _foo/name_, but no _foo/bar/name_)                                        |\n| **.name         | Package should end with _name_ and anything before, supporting multiple levels (for example either _foo/name_ and _foo/bar/name_)                                    |\n| **.*name        | Package should end with suffix _name_ and anything before, supporting multiple levels (for example either _foo/examplename_ and _foo/bar/examplename_)               |\n| **.name\\*       | Package should start with prefix _name_ and anything before, supporting multiple levels (for example either _foo/nameexample_ and _foo/bar/nameexample_)             |\n| name.*          | Package should start with _name_ and anything before, supporting only one level (for example _name/foo_, but no _name/foo/bar_)                                      |\n| name.**         | Package should start with _name_ and anything before, supporting multiple levels (for example either _name/foo_ and _name/foo/bar_)                                  |\n| \\*\\*.name.**    | Package should contain _name_, supporting multiple levels before and after (for example both _foo/name/x/y/z_, _foo/bar/name_ and _foo/bar/name/x_)                  |\n| \\*\\*.foo/bar.** | Package should contain _foo/bar_, supporting multiple levels before and after (for example both _x/y/foo/bar/w/z_, _foo/bar/name_ and _x/y/foo/bar_)                 |\n| foo.**.bar      | Package should start with _foo_, and ends with _bar_, and can have anything between them. (for example _foo/bar_, _foo/test/blah/bar_ and _foo/ok/bar_)              |\n| foo.*.bar       | Package should start with _foo_, and ends with _bar_, and can have only one level between them. (for example _foo/bar_ and _foo/ok/bar_, but no _foo/test/blah/bar_) |\n\n## Threshold configuration\nCurrent version supports threshold configuration for compliance and coverage rate. By default both limits are set to 100%.\n\n### Compliance rate threshold\nRepresents how much the compliance level of the module is considering all the rules defined in the `arch-go.yml` file. For example, if there are 4 rules and the module meets 3 of them, then its compliance level will be 75%.\n\nArch-Go will check that the compliance level of your module must be equals or greater than the compliance threshold defined in your `arch-go.yml` file, if not then the verification will fail.\n\n### Coverage rate threshold\nRepresents how many packages in this module were evaluated by at least one rule.\n* At this moment Arch-Go doesn't analize internal components as structs, interfaces, functions or methods, just verifies if a certain package complies with a rule package pattern, so then this rule is evaluated against this package\n\nArch-Go will check that the coverage level of your module must be equals or greater than the threshold defined in your `arch-go.yml` file, if not then the verification will fail.\n\n# Usage\n\n## Using Arch-Go in command line\n\nTo install Arch-Go, run\n```bash\n$ go install -v github.com/arch-go/arch-go/v2@latest\n```\n\nTo execute this tool you have to be in the module path\n```bash\n$ cd [path-to-your-module]\n```\n\nNow you can execute Arch-Go tool\n```bash\n$ arch-go [flags]\n```\n\n### Describing your architecture guidelines\nArch-Go includes a command to describe the architecture rules from `arch-go.yml` file.\n\n```bash\n$ arch-go describe\n```\nThe output of the `describe` command is similar to:\n```\n$ arch-go describe\nDependency Rules\n        * Packages that match pattern '**.cmd.*',\n                * Should only depends on packages that matches:\n                        - '**.arch-go.**'\nFunction Rules\n        * Packages that match pattern '**.arch-go.**' should comply with the following rules:\n                * Functions should not have more than 50 lines\n                * Functions should not have more than 4 parameters\n                * Functions should not have more than 2 return values\n                * Files should not have more than 5 public functions\nContent Rules\n        * Packages that match pattern '**.impl.model' should not contain functions or methods\n        * Packages that match pattern '**.impl.config' should only contain functions\nNaming Rules\n        * Packages that match pattern '**.arch-go.**' should comply with:\n                * Structs that implement interfaces matching name '*Verification' should have simple name ending with 'Verification'\nThreshold Rules\n        * The module must comply with at least 100% of the rules described above.\n        * The rules described above must cover at least 100% of the packages in this module.\n\nTime: 0.000 seconds\n```\n\n## Supported flags\n\n| Flag      | Description                                                                                                                              |\n|-----------|:-----------------------------------------------------------------------------------------------------------------------------------------|\n| --color   | If not set (default: auto) in a tty the colors are printed. If set to yes or no the default is overridden. This can be useful in the CI. |\n| --verbose | Includes detailed information while the command is running. The shorthand is _-v_                                                        |\n| --html    | Generates an HTML report with the evaluation result. The HTML report is generated in `.arch-go/report.html`                              |\n| --json    | Generates a JSON report with the evaluation result. The JSON report is generated in `.arch-go/report.json`                               |\n\n\n## Examples\n```bash\n$ arch-go \n$ arch-go -v\n$ arch-go --verbose\n$ arch-go --html\n$ arch-go --json\n$ arch-go --color\n$ arch-go describe\n```\n\n## Using Arch-Go programmatically\nThe current version of Arch-Go allows us to include architecture checks as part of the tests run by the go test tool.\n\nYou need to include Arch-Go as a dependency in your project, using\n```\ngo get github.com/arch-go/arch-go@latest\n```\n\nThen you need to create Architecture Tests, there is an example of a simple test case:\n```go\npackage architecture_test\n\nimport (\n\t\"testing\"\n\n\tarchgo \"github.com/arch-go/arch-go/api\"\n\tconfig \"github.com/arch-go/arch-go/api/configuration\"\n)\n\nfunc TestArchitecture(t *testing.T) {\n\tconfiguration := config.Config{\n\t\tDependenciesRules: []*config.DependenciesRule{\n\t\t\t{\n\t\t\t\tPackage: \"**.cmd.**\",\n\t\t\t\tShouldOnlyDependsOn: \u0026config.Dependencies{\n\t\t\t\t\tInternal: []string{\n\t\t\t\t\t\t\"**.cmd.**\",\n\t\t\t\t\t\t\"**.internal.**\",\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t}\n\tmoduleInfo := config.Load(\"github.com/arch-go/my-go-project\")\n\n\tresult := archgo.CheckArchitecture(moduleInfo, configuration)\n\n\tif !result.Pass {\n\t\tt.Fatal(\"Project doesn't pass architecture tests\")\n\t}\n}\n```\nThe `result` variable will store more than the verification result, \nincluding details for each rule type and analyzed packages, \nso then you can access all this data to create assertions as you need.\n\n\n\n# Contributions\nFeel free to contribute.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farch-go%2Farch-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farch-go%2Farch-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farch-go%2Farch-go/lists"}