title: How to initialize error type in if-else
body: <p>In the code snippet below, how do I initialize an error variable?</p>
  
  <pre><code>err := nil                // can not compile, show "use of untyped nil"
  if xxx {
      err = funcA()
  } else {
      err = funcB()
  }
  if err != nil {
      panic(err)
  }
  </code></pre>
  
  <p>As you can see above, <code>err</code> will be used in the if-else blocks. I want to use one variable to get the result, but how do I initialize <code>err</code> here. Thanks!  </p>