Files
hugo/docs/content/en/functions/os.Stat.md
2021-12-08 08:54:25 +01:00

1.1 KiB

title, description, date, publishdate, lastmod, categories, menu, keywords, signature, workson, hugoversion, relatedfuncs, deprecated, aliases
title description date publishdate lastmod categories menu keywords signature workson hugoversion relatedfuncs deprecated aliases
os.Stat Returns a FileInfo structure describing a file or directory. 2018-08-07 2018-08-07 2021-11-26
functions
docs
parent
functions
files
os.Stat PATH
os.FileExists
os.ReadDir
os.ReadFile
false

The os.Stat function attempts to resolve the path relative to the root of your project directory. If a matching file or directory is not found, it will attempt to resolve the path relative to the [contentDir]({{< relref "getting-started/configuration#contentdir">}}). A leading path separator (/) is optional.

{{ $f := os.Stat "README.md" }}
{{ $f.IsDir }}    --> false (bool)
{{ $f.ModTime }}  --> 2021-11-25 10:06:49.315429236 -0800 PST (time.Time)
{{ $f.Name }}     --> README.md (string)
{{ $f.Size }}     --> 241 (int64)

{{ $d := os.Stat "content" }}
{{ $d.IsDir }}    --> true (bool)

Details of the FileInfo structure are available in the Go documentation.