title: Detect deadlock between a group of goroutines
body: <p>Golang can detect deadlocks when all goroutines are stuck. But is it possible to detect if a group of goroutines are stuck? For example in the following code goroutine 1 and 2 will be in a deadlock but the program continues working because the main goroutine is not stuck. My question is how can I detect that goroutine 1 and 2 as a group are in a deadlock because all members of the group are stuck?</p>
  
  <pre><code>func main() {
      ch1 := make(chan int)
      ch2 := make(chan int)
  
      // goroutine 1
      go func() {
          ch1 &lt;- 12
          ch2 &lt;- 13 // oh oh, wrong channel. deadlock between goroutine 1 and 2
      }()
  
      // goroutine 2
      go func() {
          println(&lt;-ch1)
          println(&lt;-ch1)
      }()
  
      for {
          // i'm busy
          time.Sleep(time.Second)
      }
  }
  </code></pre>