Skip to content

spinning-select-default

Detect select loops that spin on an empty default.

Updated View as Markdown

Default severity: warning

An empty default makes a select immediately ready. Inside an unconditional loop, this prevents the goroutine from blocking and consumes CPU continuously. Remove the empty default so the select can wait for a communication case.

Bad

for { select { case value := <-values: use(value); default: } }

Good

for { select { case value := <-values: use(value) } }
Navigation

Type to search…

↑↓ navigate↵ selectEsc close