Skip to content

Instantly share code, notes, and snippets.

@evanphx
Last active August 29, 2015 14:18
Show Gist options
  • Save evanphx/04867d5803280fff3b2f to your computer and use it in GitHub Desktop.
Save evanphx/04867d5803280fff3b2f to your computer and use it in GitHub Desktop.
you had one job stat
package main
import (
"fmt"
"os"
"syscall"
)
const path = "/home/vagrant/blah"
func main() {
f, err := os.Create(path)
if err != nil {
panic(err)
}
fi, err := os.Stat(path)
if err != nil {
panic(err)
}
f.Close()
os.Remove(path)
f, err = os.Create(path)
if err != nil {
panic(err)
}
fi2, err := os.Stat(path)
// f.Close()
fmt.Printf("%#v\n%#v\n",
fi.Sys().(*syscall.Stat_t),
fi2.Sys().(*syscall.Stat_t))
}
vagrant@vagrant-ubuntu-trusty-64:~/go/src/github.com/vektra/cypress/testdata$ rm /home/vagrant/blah
vagrant@vagrant-ubuntu-trusty-64:~/go/src/github.com/vektra/cypress/testdata$ go run statsucks.go
&syscall.Stat_t{Dev:0x801, Ino:0x22566, Nlink:0x1, Mode:0x81b4, Uid:0x3e8, Gid:0x3e8, X__pad0:0, Rdev:0x0, Size:0, Blksize:4096, Blocks:0, Atim:syscall.Timespec{Sec:1428012709, Nsec:188498202}, Mtim:syscall.Timespec{Sec:1428012709, Nsec:188498202}, Ctim:syscall.Timespec{Sec:1428012709, Nsec:188498202}, X__unused:[3]int64{0, 0, 0}}
&syscall.Stat_t{Dev:0x801, Ino:0x22566, Nlink:0x1, Mode:0x81b4, Uid:0x3e8, Gid:0x3e8, X__pad0:0, Rdev:0x0, Size:0, Blksize:4096, Blocks:0, Atim:syscall.Timespec{Sec:1428012709, Nsec:188498202}, Mtim:syscall.Timespec{Sec:1428012709, Nsec:188498202}, Ctim:syscall.Timespec{Sec:1428012709, Nsec:188498202}, X__unused:[3]int64{0, 0, 0}}
AAAAARG
vagrant@vagrant-ubuntu-trusty-64:~/go/src/github.com/vektra/cypress/testdata$ ./statsucks
&syscall.Stat_t{Dev:0x801, Ino:0x22563, Nlink:0x1, Mode:0x81b4, Uid:0x3e8, Gid:0x3e8, X__pad0:0, Rdev:0x0, Size:0, Blksize:4096, Blocks:0, Atim:syscall.Timespec{Sec:1428020909, Nsec:569816173}, Mtim:syscall.Timespec{Sec:1428020910, Nsec:745209975}, Ctim:syscall.Timespec{Sec:1428020910, Nsec:745209975}, X__unused:[3]int64{0, 0, 0}}
&syscall.Stat_t{Dev:0x801, Ino:0x22563, Nlink:0x1, Mode:0x81b4, Uid:0x3e8, Gid:0x3e8, X__pad0:0, Rdev:0x0, Size:0, Blksize:4096, Blocks:0, Atim:syscall.Timespec{Sec:1428020910, Nsec:745209975}, Mtim:syscall.Timespec{Sec:1428020910, Nsec:745209975}, Ctim:syscall.Timespec{Sec:1428020910, Nsec:745209975}, X__unused:[3]int64{0, 0, 0}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment