title: Avoid checking if error is nil repetition?
body: <p>I'm currently learning go and some of my code looks like this:</p>
  
  <pre><code>a, err := doA()
  if err != nil {
    return nil, err
  }
  b, err := doB(a)
  if err != nil {
    return nil, err
  }
  c, err := doC(b)
  if err != nil {
    return nil, err
  }
  ... and so on ...
  </code></pre>
  
  <p>This looks kinda wrong to me because the error checking takes most of the lines. Is there a better way to do error handling? Can I maybe avoid this with some refactoring?</p>
  
  <p><strong>UPDATE:</strong> Thank you for all the answers. Please note that in my example doB depends on a, doC depends on b and so on. Therefore most suggested refactorings don't work in this case. Any other suggestion?</p>