loov / enumcheck

Allows to mark Go enum types as exhaustive.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Annotate individual switches

egonelbre opened this issue · comments

Sometimes it makes more sense to annotate every exhaustive switch separately.

Fixed with 8aa7b78

//enumcheck:silent
type Option string

var (
	Alpha = Option("alpha")
	Beta  = Option("beta")
)

func NoErrorHere() {
	var day Option
	switch day {
	case Beta:
		fmt.Println("beta")
	}
}

func EnablePerSwitch() {
	var day Option
	switch day { //enumcheck:exhaustive
	case Beta:
		fmt.Println("beta")
	}
}