{"id":16581903,"url":"https://github.com/nishanths/exhaustive","last_synced_at":"2025-05-14T03:10:46.903Z","repository":{"id":38462940,"uuid":"265183027","full_name":"nishanths/exhaustive","owner":"nishanths","description":"Check exhaustiveness of switch statements of enum-like constants in Go source code.","archived":false,"fork":false,"pushed_at":"2024-12-05T04:16:32.000Z","size":373,"stargazers_count":312,"open_issues_count":7,"forks_count":11,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-12T17:45:12.192Z","etag":null,"topics":["ast","go","types","vet"],"latest_commit_sha":null,"homepage":"https://pkg.go.dev/github.com/nishanths/exhaustive","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nishanths.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}},"created_at":"2020-05-19T07:58:40.000Z","updated_at":"2025-04-04T18:24:52.000Z","dependencies_parsed_at":"2023-02-17T05:35:16.789Z","dependency_job_id":"ea2699fc-5bae-4d38-9477-9d2111395e9f","html_url":"https://github.com/nishanths/exhaustive","commit_stats":{"total_commits":251,"total_committers":8,"mean_commits":31.375,"dds":0.03984063745019917,"last_synced_commit":"b6bf430e32d13b142d507e7e4c75b19c03214080"},"previous_names":[],"tags_count":45,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nishanths%2Fexhaustive","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nishanths%2Fexhaustive/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nishanths%2Fexhaustive/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nishanths%2Fexhaustive/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nishanths","download_url":"https://codeload.github.com/nishanths/exhaustive/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254059512,"owners_count":22007769,"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":["ast","go","types","vet"],"created_at":"2024-10-11T22:30:15.366Z","updated_at":"2025-05-14T03:10:41.854Z","avatar_url":"https://github.com/nishanths.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"# exhaustive\n\n[![Godoc][godoc-svg]][godoc]\n\n`exhaustive` checks exhaustiveness of enum switch statements in Go source code.\n\nFor the definition of enum and the definition of exhaustiveness used by this\nprogram, see [godoc][godoc-doc]. For the changelog, see [CHANGELOG][changelog]\nin the GitHub wiki. The program can be configured to additionally check\nexhaustiveness of keys in map literals whose key type is an enum.\n\n## Usage\n\nCommand:\n\n```\ngo install github.com/nishanths/exhaustive/cmd/exhaustive@latest\n\nexhaustive [flags] [packages]\n```\n\nFor available flags, refer to the [Flags][godoc-flags] section in godoc or run\n`exhaustive -h`.\n\nPackage:\n\n```\ngo get github.com/nishanths/exhaustive\n\nimport \"github.com/nishanths/exhaustive\"\n```\n\nThe `exhaustive.Analyzer` variable follows guidelines in the\n[`golang.org/x/tools/go/analysis`][xanalysis] package. This should make it\npossible to integrate `exhaustive` with your own analysis driver program.\n\n## Example\n\nGiven an enum:\n\n```go\npackage token // import \"example.org/token\"\n\ntype Token int\n\nconst (\n\tAdd Token = iota\n\tSubtract\n\tMultiply\n\tQuotient\n\tRemainder\n)\n```\n\nand code that switches on the enum:\n\n```go\npackage calc\n\nimport \"example.org/token\"\n\nfunc x(t token.Token) {\n\tswitch t {\n\tcase token.Add:\n\tcase token.Subtract:\n\tcase token.Remainder:\n\tdefault:\n\t}\n}\n```\n\nrunning `exhaustive` with default flags will produce:\n\n```\ncalc.go:6:2: missing cases in switch of type token.Token: token.Multiply, token.Quotient\n```\n\nSpecify flag `-check=switch,map` to additionally check exhaustiveness of keys\nin map literals. For example:\n\n```go\nvar m = map[token.Token]rune{\n\ttoken.Add:      '+',\n\ttoken.Subtract: '-',\n\ttoken.Multiply: '*',\n\ttoken.Quotient: '/',\n}\n```\n\n```\ncalc.go:14:9: missing keys in map of key type token.Token: token.Remainder\n```\n\n## Contributing\n\nIssues and changes are welcome. Please discuss substantial changes in an issue\nfirst.\n\n[godoc]: https://pkg.go.dev/github.com/nishanths/exhaustive\n[godoc-svg]: https://pkg.go.dev/badge/github.com/nishanths/exhaustive.svg\n[godoc-doc]: https://pkg.go.dev/github.com/nishanths/exhaustive#section-documentation\n[godoc-flags]: https://pkg.go.dev/github.com/nishanths/exhaustive#hdr-Flags\n[xanalysis]: https://pkg.go.dev/golang.org/x/tools/go/analysis\n[changelog]: https://github.com/nishanths/exhaustive/wiki/CHANGELOG\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnishanths%2Fexhaustive","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnishanths%2Fexhaustive","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnishanths%2Fexhaustive/lists"}