{"id":20198363,"url":"https://github.com/uudashr/iface","last_synced_at":"2025-10-04T02:24:47.795Z","repository":{"id":247419863,"uuid":"825790299","full_name":"uudashr/iface","owner":"uudashr","description":"Linter to detects the overuse or misuse of interfaces in Go code AKA \"Interface Pollution\"","archived":false,"fork":false,"pushed_at":"2025-06-30T17:14:45.000Z","size":106,"stargazers_count":16,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-06-30T18:22:10.310Z","etag":null,"topics":["analyzer","anti-pattern","go","golang","linter"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/uudashr.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":"2024-07-08T13:57:45.000Z","updated_at":"2025-06-30T17:13:26.000Z","dependencies_parsed_at":"2024-07-12T05:43:39.798Z","dependency_job_id":"c8a3d413-e234-43b6-88e6-2c9e41a2579d","html_url":"https://github.com/uudashr/iface","commit_stats":null,"previous_names":["uudashr/iface"],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/uudashr/iface","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uudashr%2Fiface","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uudashr%2Fiface/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uudashr%2Fiface/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uudashr%2Fiface/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/uudashr","download_url":"https://codeload.github.com/uudashr/iface/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uudashr%2Fiface/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278254666,"owners_count":25956644,"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","status":"online","status_checked_at":"2025-10-04T02:00:05.491Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["analyzer","anti-pattern","go","golang","linter"],"created_at":"2024-11-14T04:30:41.394Z","updated_at":"2025-10-04T02:24:47.789Z","avatar_url":"https://github.com/uudashr.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Go Reference](https://pkg.go.dev/badge/github.com/uudashr/iface.svg)](https://pkg.go.dev/github.com/uudashr/iface)\n\n# iface\n\n`iface` is a linter designed to identify the incorrect use of interfaces in Go code, helping developers avoid interface pollution. By detecting unnecessary or poorly implemented interfaces, `iface` ensures your Go code remains clean, efficient, and maintainable.\n\nIt consists of several analyzers:\n1. `unused`: Detects interfaces which are not used anywhere in the same package where they are defined.\n2. `identical`: Detects interfaces within the same package that have identical methods or type constraints.\n3. `opaque`: Detects functions that return an interface type, but only ever return a single concrete implementation.\n4. `unexported`: Detects interfaces which are not exported but are used as parameters or return values in exported functions or methods.\n\n## Usage\n\nTo install the linter which has all the checks:\n```sh\ngo install github.com/uudashr/iface/cmd/ifacecheck@latest\n```\n\nTo install individual linter, use the following command:\n```sh\ngo install github.com/uudashr/iface/unused/cmd/unusediface@latest\ngo install github.com/uudashr/iface/identical/cmd/identicaliface@latest\ngo install github.com/uudashr/iface/opaque/cmd/opaqueiface@latest\ngo install github.com/uudashr/iface/unexported/cmd/unexportediface@latest\n```\n\nRun the linter\n```sh\nifacecheck ./...\n```\n\nor show the help\n```sh\nifacecheck help\n\n# or\nifacecheck help \u003canalyzer-name\u003e\n```\n\n## Exclusion\n\n### Package exclusion\n\nWe encourage to use default behavior and put effot to follow the rules. But, for some reason rules are not applicable. Due to this we can exclude specific package to be scanned by the analyzers. Use `-unused.exclude` flag and currently only `unused` has this feature. See help for more information:\n\nExample usage: \n```sh\nifacecheck -unused.exclude=github.com/example/log ./...\n```\n\n### Ignore Directive\n\nExclusion can be done by using directive in the code by placing the `//iface:ignore` to ignore the code from being scanned by the analyzer. Example:\n\n1. `iface:ignore` to ignore the from all analyzers.\n2. `iface:ignore=[analyzer names]` which names is comma separators to exclude from defined names only. Ex: \n    - `iface:ignore=unused` ignore from `unused` analyzer.\n    - `iface:ignore=unused,identical` ignore from `unused` and `identical` analyzers.\n\n\nNote: use exclusion with careful consideration.\n\n## Background\n\nOne of Go's powerful features is interfaces. However, sometimes people misuse the interfaces event though the code works but the code polluted with interfaces.\n\nThe following quotes inspired the creation of these analyzers:\n\n\u003e \"Go interfaces generally belong in the package that uses values of the interface type, not the package that implements those values. The implementing package should return concrete (usually pointer or struct) types: that way, new methods can be added to implementations without requiring extensive refactoring.\"\n\u003e\n\u003e [Go Code Review Comments, go.dev](https://go.dev/wiki/CodeReviewComments#interfaces)\n\n\n\u003e \"Don’t export any interfaces until you have to.\"\n\u003e\n\u003e [Interface pollution in Go, rakyll.org](https://rakyll.org/interface-pollution/)\n\n\n\u003e \"The use of interfaces when they are not necessary is called interface pollution.\"\n\u003e \n\u003e [Avoid Interface Pollution, ardanlabs.com](https://www.ardanlabs.com/blog/2016/10/avoid-interface-pollution.html)\n\n\u003e \"Go interfaces generally belong in the package that consumes values of the interface type, not a package that implements the interface type.\"\n\u003e\n\u003e [Go Style Decisions, google.github.io](https://google.github.io/styleguide/go/decisions#interfaces)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fuudashr%2Fiface","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fuudashr%2Fiface","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fuudashr%2Fiface/lists"}