Skip to content

Instantly share code, notes, and snippets.

@igm
Last active December 17, 2015 23:09
Show Gist options
  • Save igm/5687664 to your computer and use it in GitHub Desktop.
Save igm/5687664 to your computer and use it in GitHub Desktop.
Routine leak
package main
import "time"
func main() {
ch := make(chan bool)
go func() {
// e.g. do some unpredictable long socket read
<-time.After(2 * time.Second)
ch <- true
}()
// e.g. wait for socket read of timeout
select {
case <-time.After(1 * time.Second):
// timeout causes routine leak
case <-ch:
}
<-time.After(3 * time.Second)
panic("")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment