{"id":13764120,"url":"https://github.com/mvdan/interfacer","last_synced_at":"2025-05-10T17:31:40.866Z","repository":{"id":57480527,"uuid":"47480820","full_name":"mvdan/interfacer","owner":"mvdan","description":"A linter that suggests interface types","archived":true,"fork":false,"pushed_at":"2018-09-01T00:41:13.000Z","size":556,"stargazers_count":691,"open_issues_count":0,"forks_count":17,"subscribers_count":12,"default_branch":"master","last_synced_at":"2024-11-16T23:32:36.421Z","etag":null,"topics":["go","interface","linter","types"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mvdan.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":"2015-12-06T02:27:57.000Z","updated_at":"2024-10-05T15:18:13.000Z","dependencies_parsed_at":"2022-09-13T03:11:11.513Z","dependency_job_id":null,"html_url":"https://github.com/mvdan/interfacer","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mvdan%2Finterfacer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mvdan%2Finterfacer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mvdan%2Finterfacer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mvdan%2Finterfacer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mvdan","download_url":"https://codeload.github.com/mvdan/interfacer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253453356,"owners_count":21911082,"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":["go","interface","linter","types"],"created_at":"2024-08-03T15:01:14.567Z","updated_at":"2025-05-10T17:31:40.420Z","avatar_url":"https://github.com/mvdan.png","language":"Go","funding_links":[],"categories":["Linters","Code Analysis","代碼分析","代码分析"],"sub_categories":["Style and Patterns Checking","路由","Routers","路由器","Middlewares"],"readme":"# interfacer\n\n[![GoDoc](https://godoc.org/mvdan.cc/interfacer?status.svg)](https://godoc.org/mvdan.cc/interfacer)\n[![Build Status](https://travis-ci.org/mvdan/interfacer.svg?branch=master)](https://travis-ci.org/mvdan/interfacer)\n\n**Deprecated**: A tool that suggests interfaces is prone to bad suggestions, so\nits usefulness in real code is limited. This tool will remain available as a\nproof of concept, and for others to examine and learn from.\n\nA linter that suggests interface types. In other words, it warns about\nthe usage of types that are more specific than necessary.\n\n\tgo get -u mvdan.cc/interfacer\n\nNote that this linter's suggestions tend to be subjective, as interfaces\nare not always the better option. You should select the proposed changes\nthat make sense in your codebase, instead of following all of them\nblindly.\n\n### Usage\n\n```go\nfunc ProcessInput(f *os.File) error {\n        b, err := ioutil.ReadAll(f)\n        if err != nil {\n                return err\n        }\n        return processBytes(b)\n}\n```\n\n```sh\n$ interfacer ./...\nfoo.go:10:19: f can be io.Reader\n```\n\n### Basic idea\n\nThis tool inspects the parameters of your functions to see if they fit\nan interface type that is less specific than the current type.\n\nThe example above illustrates this point. Overly specific interfaces\nalso trigger a warning - if `f` were an `io.ReadCloser`, the same\nmessage would appear.\n\nIt suggests interface types defined both in the func's package and the\npackage's imports (two levels; direct imports and their direct imports).\n\n### False positives\n\nTo avoid false positives, it never does any suggestions on functions\nthat may be implementing an interface method or a named function type.\n\nIt also skips parameters passed by value (excluding pointers and\ninterfaces) on unexported functions, since that would introduce extra\nallocations where they are usually not worth the tradeoff.\n\n### Suppressing warnings\n\nIf a suggestion is technically correct but doesn't make sense, you can\nstill suppress the warning by mentioning the type in the function name:\n\n```go\nfunc ProcessInputFile(f *os.File) error {\n\t// use as an io.Reader\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmvdan%2Finterfacer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmvdan%2Finterfacer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmvdan%2Finterfacer/lists"}