title: How do I detect a change to the filename of an open file in Golang
body: <p>Using Go, I was writing a small utility that in part needs to notice if the filename of an open file changes. The below code illustrates the approach I tried:</p>
  
  <pre><code>package main
  
  import "os"
  import "fmt"
  import "time"
  
  func main() {
  
      path := "data.txt"
      file, _ := os.Open(path)
  
      for {
          details, _ := file.Stat()
          fmt.Println(details.Name())
          time.Sleep(5 * time.Second)
      }
  }
  </code></pre>
  
  <p>This just starts an endless loop, running <code>file.Stat()</code> to obtain file details every 5 seconds and then printing out the name. However, despite changing the filename as this is running, the output of the above does not change.</p>
  
  <p>replacing <code>details.Name()</code> with <code>details.Size()</code> does however notice changes to the filesize.</p>
  
  <p>Is this simply a bug in my version of Go, or am I just doing things wrong? I cannot find mention of such an issue anywhere offhand.</p>
  
  <p>I am running this on a Mac, with Go version 1.1.1 (darwin/amd64).</p>
  
  <p>Thanks in advance for any replies :)</p>