title: Reading outputs from two channels in a forever loop
body: <p>I am working on the tree exercise of <a href="https://tour.golang.org/concurrency/8" rel="nofollow noreferrer">tour.golang</a>. I have tried to implement the same function as written below.</p>
  
  <pre><code>func Same(t1, t2 *tree.Tree) bool {
      ch1 := make(chan int)
      ch2 := make(chan int)
      go Walk(t1, ch1);
      go Walk(t2, ch2);
  
      for c := range ch1 {
          d := &lt;- ch2
          if c-d !=0 {
              return false
          }   
  
      }
      return true
  }
  </code></pre>
  
  <p>Using the forever loop, I would like to compare if an output from <code>ch1</code> is different from that of <code>ch2</code>. But the following is throwing this error:</p>
  
  <blockquote>
    <p>fatal error: all goroutines are asleep - deadlock!</p>
  </blockquote>
  
  <p><a href="https://play.golang.org/p/RQ0yq0H7LUK" rel="nofollow noreferrer">live version</a></p>