diff options
author | Rob Pike <r@golang.org> | 2012-02-12 09:17:57 +1100 |
---|---|---|
committer | Rob Pike <r@golang.org> | 2012-02-12 09:17:57 +1100 |
commit | 46dc76f5daa5e1186a5c4f2299bd4b4ff82e60d0 (patch) | |
tree | 41529a74da1fb1e5d27d6aadfa7bb09bf9f3af3a /doc/go1.html | |
parent | 14efdea35986e47db79c8b1e8d5e57dc13e8727a (diff) | |
download | go-git-46dc76f5daa5e1186a5c4f2299bd4b4ff82e60d0.tar.gz |
go1: update recipe for recovering Stat_t
Fixes #2983.
R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/5654063
Diffstat (limited to 'doc/go1.html')
-rw-r--r-- | doc/go1.html | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/doc/go1.html b/doc/go1.html index 0dc73234f6..6e63882f09 100644 --- a/doc/go1.html +++ b/doc/go1.html @@ -1420,6 +1420,7 @@ changing it from a struct to an interface: Mode() FileMode // file mode bits ModTime() time.Time // modification time IsDir() bool // abbreviation for Mode().IsDir() + Sys() interface{} // underlying data source (can return nil) } </pre> @@ -1435,7 +1436,7 @@ The system-specific details of file modes and properties such as (on Unix) i-number have been removed from <code>FileInfo</code> altogether. Instead, each operating system's <code>os</code> package provides an implementation of the <code>FileInfo</code> interface, <code>*os.FileStat</code>, -which in turn contains a <code>Sys</code> field that stores the +which has a <code>Sys</code> method that returns the system-specific representation of file metadata. For instance, to discover the i-number of a file on a Unix system, unpack the <code>FileInfo</code> like this: @@ -1446,13 +1447,8 @@ the <code>FileInfo</code> like this: if err != nil { log.Fatal(err) } - // Make sure it's an implementation known to package os. - fileStat, ok := fi.(*os.FileStat) - if !ok { - log.Fatal("hello.go: not an os File") - } - // Now check that it's a Unix file. - unixStat, ok := fileStat.Sys.(*syscall.Stat_t) + // Check that it's a Unix file. + unixStat, ok := fi.Sys().(*syscall.Stat_t) if !ok { log.Fatal("hello.go: not a Unix file") } |