title: Using the gofmt refactoring tool to rename a global variable
body: <p>I'm experimenting the <code>gofmt</code> tool capabilities for refactoring <a href="/questions/tagged/go" class="post-tag" title="show questions tagged &#39;go&#39;" rel="tag"><img src="https://i.stack.imgur.com/sawHl.png" height="16" width="18" alt="" class="sponsor-tag-img">go</a> code based on this <a href="http://spf13.com/post/go-fmt" rel="noreferrer">blog post</a>, I have this trivial example:</p>
  
  <pre><code>package main
  
  import (
      "fmt"
  )
  
  var v = 12
  
  func main() {
      fmt.Println(v)
  }
  </code></pre>
  
  <p>I'm trying to <strong>rename</strong> the <code>v</code> variable to <code>m</code>applying this recipe:</p>
  
  <pre><code>gofmt -r 'v -&gt; m' -w main.go
  </code></pre>
  
  <p>The code after the refactoring looks (broken) like:</p>
  
  <pre><code>package m
  
  import (
      "fmt"
  )
  
  var m = m
  
  func m() {
      m
  }
  </code></pre>
  
  <p>What am I missing here?</p>