title: How to handle errors in goroutines?
body: <p>I'm trying to run several tasks concurrently and get the result or error back.</p>
  
  <pre><code>//data channels
      ch := make(chan int)
      ch2 := make(chan int)
      ch2 := make(chan int)
  //error channels 
  
     errCh := make(chan error)
      errCh2 := make(chan error)
      errCh3 := make(chan error)
  
   //functions 
          go taskF(ch, errCh)
          go taskF2(ch2, errCh2)
          go taskF3(ch3, errCh3)
  </code></pre>
  
  <p>Then I start checking on each error. If there is any error we print it otherwise we print the result of each task</p>
  
  <pre><code>      err := &lt;-errCh
        if err != nil{
             print('we have an error ')
         return  
    }
            err2 := &lt;-errCh2
            if err2 != nil{
             print('we have an error 2')
             return  
    }
         err3 := &lt;-errCh3
        if err3!= nil{
             print('we have an error 3')
             return   
   }
  </code></pre>
  
  <p>Then if there is no error I collect the values returned though each channel </p>
  
  <pre><code>task := &lt;-ch
  task2 := &lt;-ch2
  task3 := &lt;-ch3
  
  print("task %v task2 %v task3 %v", task, task2, task3)
  </code></pre>
  
  <p>I'm wondering if I'm doing it right. I'm worried that the code quite verbose. I was thinking to use buffered channels for errors but i can't figure it out how to check all the errors. I think it would also be nice to somehow sync the errors within the goroutines so that if there is an error on one goroutine the other goroutines would stop but I don't know any way to do in an unblocking manner.</p>