- Hands-On System Programming with Go
- Alex Guerrieri
- 86字
- 2021-06-24 13:42:29
Stats
The os package offers the FileInfo interface, which returns the metadata of a file, as shown in the following code:
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)
}
The os.Stat function returns information about the file with the specified path.