Skip to content

Instantly share code, notes, and snippets.

@jhawk28
Created January 15, 2014 02:20
Show Gist options
  • Save jhawk28/8429703 to your computer and use it in GitHub Desktop.
Save jhawk28/8429703 to your computer and use it in GitHub Desktop.
fd move test
package main
import (
"fmt"
"io/ioutil"
"os"
"time"
)
func main() {
f, _ := os.Open("hello.txt")
fmt.Println("Sleeping while file is renamed")
time.Sleep(time.Second * 10)
fmt.Println("opening same file with new name")
f1, _ := os.Open("hello1.txt")
d, _ := ioutil.ReadAll(f)
d1, _ := ioutil.ReadAll(f1)
fmt.Println(string(d))
fmt.Println(string(d1))
s, _ := f.Stat()
s1, _ := f1.Stat()
fmt.Println(s.Name())
fmt.Println(s1.Name())
}
@jhawk28
Copy link
Author

jhawk28 commented Jan 15, 2014

Example output:

$ go run file.go
Sleeping
opening new file
123
456
123
456
hello.txt
hello1.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment