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.