cmd/vet: Add check for channels that must be buffered #9399
There are at least two places in the standard library where channels must have a non-zero buffer in order for the program to be correct:
I propose a vet check that ensures that these channels are buffered.
I took a quick look at @rsc's pubgo dataset (circa early 2013), and in the code that compiles, I found 161 calls to
I currently have a vet check written that ensures that all calls to
This was originally discussed on the mailing list.
The text was updated successfully, but these errors were encountered:
Unbuffered channels passed into signal.Notify can be lost as the docs for signal.Notify caution with: Package signal will not block sending to c: the caller must ensure that c has sufficient buffer space to keep up with the expected signal rate. For a channel used for notification of just one signal value, a buffer of size 1 is sufficient. Found by a static analyzer from Orijtech, Inc. called "sigchanyzer", but it'll be donated to the Go project soon. Updates #9399. Change-Id: Ia0690e447582da028694ed65ace7b97961997b84 Reviewed-on: https://go-review.googlesource.com/c/go/+/274332 Trust: Cuong Manh Le <firstname.lastname@example.org> Trust: Emmanuel Odeke <email@example.com> Run-TryBot: Cuong Manh Le <firstname.lastname@example.org> Reviewed-by: Bryan C. Mills <email@example.com> Reviewed-by: Emmanuel Odeke <firstname.lastname@example.org> TryBot-Result: Go Bot <email@example.com>
This if follow up of CL 274332. Updates #9399. Change-Id: Ic6dd534dc18227a799cbb9577979f2285596b825 Reviewed-on: https://go-review.googlesource.com/c/go/+/274393 Trust: Cuong Manh Le <firstname.lastname@example.org> Run-TryBot: Cuong Manh Le <email@example.com> TryBot-Result: Go Bot <firstname.lastname@example.org> Reviewed-by: Ian Lance Taylor <email@example.com>