switchchecker
This Repository is inspired from https://github.com/knightso/allcases
Install
$ go get github.com/esh2n/switchchecker/cmd/switchchecker
How to use
Usage
$ allcases [-flag] [package]
Annotation
This checker checks for switch statements which have an annotation comment // switchchecker
to have all cases for consts of the expression type.
For example if there is a type and consts like:
type TestKind int
const (
TestKindHoge TestKind = iota
TestKindFuga
TestKindPiyo
)
and switch statements like:
// allcases
switch v {
case TestKindHoge:
// do something
case TestKindFuga:
// do something
}
and also exclude case like:
// allcases -exclude TestKindFuga
switch v {
case TestKindHoge:
// do something
}
then the checker reports that the switch statement doesn't have the TestKindPiyo case.