{"id":15527550,"url":"https://github.com/elliotchance/switch-check","last_synced_at":"2025-09-14T18:52:47.515Z","repository":{"id":137291241,"uuid":"261001634","full_name":"elliotchance/switch-check","owner":"elliotchance","description":"Validate switch statements contain all enum values.","archived":false,"fork":false,"pushed_at":"2020-05-09T16:10:26.000Z","size":31,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-25T01:51:07.138Z","etag":null,"topics":["enums","golang","static-analysis","static-analyzer","switch"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/elliotchance.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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-03T19:08:33.000Z","updated_at":"2021-01-16T15:22:06.000Z","dependencies_parsed_at":"2023-07-03T11:30:22.187Z","dependency_job_id":null,"html_url":"https://github.com/elliotchance/switch-check","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elliotchance%2Fswitch-check","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elliotchance%2Fswitch-check/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elliotchance%2Fswitch-check/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elliotchance%2Fswitch-check/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/elliotchance","download_url":"https://codeload.github.com/elliotchance/switch-check/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248339294,"owners_count":21087213,"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":["enums","golang","static-analysis","static-analyzer","switch"],"created_at":"2024-10-02T11:07:05.435Z","updated_at":"2025-04-11T03:43:51.339Z","avatar_url":"https://github.com/elliotchance.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"switch-check\n============\n\n`switch-check` is a tool for validating that `switch` statements contain all\nenum values.\n\n\nInstallation\n------------\n\n```bash\ngo get -u github.com/elliotchance/switch-check\n```\n\nUsage\n-----\n\n```bash\nswitch-check [options] [files or folders...]\n\n  -show-enums\n        Show all enums. Useful for debugging.\n  -verbose\n        Show all files processed.\n```\n\n\nExample\n-------\n\n```go\npackage test\n\ntype Foo int\n\nconst (\n\tFooA Foo = iota\n\tFooB\n)\n\nconst FooC = Foo(17)\nconst FooD = FooC\nvar FooE = Foo(-1)\n\nfunc fooMissingSomeValues() {\n\tfoo := FooB\n\n\tswitch foo {\n\tcase FooA:\n\tcase FooC, FooD:\n\t}\n}\n```\n\nRun with `switch-check` will output the error:\n\n```\n./test/foo.go:33:2 switch is missing cases for: FooB, FooE\n```\n\nKnown Limitations\n-----------------\n\n1. Using expressions to produce enum values are not supported. This level of\ntype inference requires the compiler (not just the AST). For example this will\nnot be recognised as a enum value:\n\n```go\nvar EnumValueA = someFuncThatReturnsAnEnumValue()\n```\n\n2. Switch statements must only switch on the value and not contain expressions\nin case statements.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felliotchance%2Fswitch-check","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Felliotchance%2Fswitch-check","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felliotchance%2Fswitch-check/lists"}