Created
January 15, 2014 02:20
-
-
Save jhawk28/8429703 to your computer and use it in GitHub Desktop.
fd move test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example output:
$ go run file.go
Sleeping
opening new file
123
456
123
456
hello.txt
hello1.txt