Skip to Content
marmot
DiagnosticsError codes

A value added to the enum later then goes unnoticed.

The mistake and the fix

The mistake
type Color int
const (Red Color = iota; Green; Blue)

switch c {
case Red, Green:
}
Fixed
switch c {
case Red, Green:
case Blue: 
	// handled, or nothing to do
}

The fix

Handle the missing values, add a default clause, or write //exhaustive:ignore on the line before the switch. marmot fix adds the missing cases with empty bodies, which keeps the behavior.

See also all error codes and marmot explain.

On this page

Was this page helpful?

Report an issueOpen issues