os.Stat

228 阅读1分钟
package osimport "internal/testlog"
// Stat returns a FileInfo describing the named file.
// If there is an error, it will be of type *PathError.
func Stat(name string) (FileInfo, error) 
{ 
  testlog.Stat(name) 
  return statNolog(name)
}

FileInfo = os.Stat(“FileName”)

// A FileInfo describes a file and is returned by Stat and Lstat.
type FileInfo interface { 
  Name() string       // base name of the file
  Size() int64        // length in bytes for regular files; system-dependent for others   
  Mode() FileMode     // file mode bits   
  ModTime() time.Time // modification time  
  IsDir() bool        // abbreviation for Mode().IsDir() 
  Sys() interface{}   // underlying data source (can return nil)
}

通过得到 FileName 获取 File 所有的信息