title: Go: error variable reassigning, proper use?
body: <p>I'm confusing about the reassignment of the <code>err</code> variable for errors in Go.</p>
  
  <p>For example, I tend to be doing this:</p>
  
  <pre><code>err1 := Something()
  checkErr(err1)
  str, err2 := SomethingElse()
  checkErr(err2)
  err3 := SomethingAgain()
  checkErr(err3)
  </code></pre>
  
  <p>But I'm always losing track of this and have millions of useless err variables floating around that I don't need, and it makes the code messy and confusing.</p>
  
  <p>But then if I do this:</p>
  
  <pre><code>err := Something()
  checkErr(err)
  str, err := SomethingElse()
  checkErr(err)
  err := SomethingAgain()
  checkErr(err)
  </code></pre>
  
  <p>...it gets angry and says <code>err</code> is already assigned.</p>
  
  <p>But if I do this:</p>
  
  <pre><code>var err error
  err = Something()
  checkErr(err)
  str, err = SomethingElse()
  checkErr(err)
  err = SomethingAgain()
  checkErr(err)
  </code></pre>
  
  <p>...it doesn't work because <code>str</code> needs to be assigned with <code>:=</code></p>
  
  <p>Am I missing something?</p>