errcheck
errcheck copied to clipboard
Check that channel receive is used with result return variable
Similarly to type assertions, channel receives val := <- ch can also be specified with another boolean result return value, val, ok := <-ch, indicating whether the channel is closed, i.e. whether val has actually been sent into the channel or it is just the zero value because the channel is closed.
I'd suggest that it makes sense checking this result to avoid working on invalid data. This linter could enforce this.
Similarly to type assertions, there should be a flag to disable the check.