The following program runs with Out of Memory due to forgotten return statement after "ctrl" channel is closed. Would there be any possibility for capturing the cases through code analysis?
package main
import (
"fmt"
"time"
)
func main() {
ctrl := make(chan struct{})
go func() {
for {
select {
case <-ctrl:
case <-time.After(5 * time.Second):
fmt.Printf("==> print status\n")
}
}
}()
time.Sleep(10 * time.Second)
close(ctrl)
// OOM: here
time.Sleep(3600 * time.Second)
}
The following program runs with Out of Memory due to forgotten
return
statement after "ctrl" channel is closed. Would there be any possibility for capturing the cases through code analysis?