https://github.com/bouk/exhaustive-enum
Exhaustive-enum is an exhaustive enum checker for Go. It can be used to make sure you don't miss any cases when switching over an enumeration.
https://github.com/bouk/exhaustive-enum
Last synced: over 1 year ago
JSON representation
Exhaustive-enum is an exhaustive enum checker for Go. It can be used to make sure you don't miss any cases when switching over an enumeration.
- Host: GitHub
- URL: https://github.com/bouk/exhaustive-enum
- Owner: bouk
- Created: 2018-07-12T09:38:02.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-07-12T09:38:12.000Z (almost 8 years ago)
- Last Synced: 2025-01-23T01:11:24.538Z (over 1 year ago)
- Language: Go
- Homepage:
- Size: 3.91 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Exhaustive-enum
Exhaustive-enum is an exhaustive enum checker for Go. It can be used to make sure you don't miss any cases when switching over an enumeration.
## Method
Find switch statements. For each:
* Find type of expression being switched over.
* Verify if the type is an enum:
1. `exhaustive-enum` annotation.
2. Type has to be a value type (not struct/interface).
3. Find all exported values in the package of the type definition.
* Verify that all the enum cases are in the switch, or that there's a default case.