staticcheck/sa1017/testdata/go1.0/CheckUnbufferedSignalChan/CheckUnbufferedSignalChan.go
raw| 1 | package pkg |
| 2 | |
| 3 | import ( |
| 4 | "os" |
| 5 | "os/signal" |
| 6 | "syscall" |
| 7 | ) |
| 8 | |
| 9 | func fn(b bool) { |
| 10 | c0 := make(chan os.Signal) |
| 11 | signal.Notify(c0, os.Interrupt) //@ diag(`the channel used with signal.Notify should be buffered`) |
| 12 | |
| 13 | c1 := make(chan os.Signal, 1) |
| 14 | signal.Notify(c1, os.Interrupt, syscall.SIGHUP) |
| 15 | |
| 16 | c2 := c0 |
| 17 | if b { |
| 18 | c2 = c1 |
| 19 | } |
| 20 | signal.Notify(c2, os.Interrupt, syscall.SIGHUP) |
| 21 | } |