errcheck icon indicating copy to clipboard operation
errcheck copied to clipboard

Check that channel receive is used with result return variable

Open fxedel opened this issue 11 months ago • 0 comments

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.

fxedel avatar Feb 07 '25 10:02 fxedel