A select has a single case and no default, so it is a plain send or receive
What it finds
select { case v := <-ch: use(v) } blocks until the one case can proceed, exactly as v := <-ch; use(v) does. The select adds a level of nesting and suggests a choice that is not there.
A select with exactly one communication clause, which is not default, is reported.
From the rule's source, single_case_select.rs.
package p func f(ch chan int, done chan struct{}) int { select { case v := <-ch: return v }tx0 reports: this select has one case, so it is a plain send or receive select { case v := <-ch: return v case <-done: return 0 }} Turn it on, off or suppress it
The rule runs from the strict tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/go:single-case-select" = "warning"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
// tx0: ignore[tx0/go:single-case-select] reason="..."tx0 explain tx0/go:single-case-select shows the same in the terminal. Found a false positive? Report it.