title: How can I not reassign a variable in go?
body: <p>I don't understand how to reassign a variable in a block scope appropriately in go.</p>
  <pre class="lang-golang prettyprint-override"><code>package main
  
  import (
      &quot;fmt&quot;
      &quot;path/filepath&quot;
  )
  
  func main() {
      base := &quot;/a/b/c&quot;
      other := &quot;/a/b/c/d/e&quot;
  
      for base != other {
          other, file := filepath.Split(other) // &quot;other declared but not used&quot;
          fmt.Println(file)
      }
  }
  </code></pre>
  <p>I want to use both parts of <code>filepath.Split</code>, so I need <code>:=</code>, since <code>file</code> is not declared yet. I want <code>other</code> to get shorter and shorter, so I reassign the result of <code>filepath.Split</code>, but the go compiler doesn't let me run this code.</p>
  <p>Why is this the case, and how am I supposed to do this sort of thing?</p>