hugo

Fork of github.com/gohugoio/hugo with reverse pagination support

git clone git://git.shimmy1996.com/hugo.git

os.Stat.md (1115B)

    1 ---
    2 title: os.Stat
    3 description: Returns a FileInfo structure describing a file or directory.
    4 date: 2018-08-07
    5 publishdate: 2018-08-07
    6 lastmod: 2021-11-26
    7 categories: [functions]
    8 menu:
    9   docs:
   10     parent: "functions"
   11 keywords: [files]
   12 signature: ["os.Stat PATH"]
   13 workson: []
   14 hugoversion:
   15 relatedfuncs: ['os.FileExists','os.ReadDir','os.ReadFile']
   16 deprecated: false
   17 aliases: []
   18 ---
   19 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.
   20 
   21 ```go-html-template
   22 {{ $f := os.Stat "README.md" }}
   23 {{ $f.IsDir }}    --> false (bool)
   24 {{ $f.ModTime }}  --> 2021-11-25 10:06:49.315429236 -0800 PST (time.Time)
   25 {{ $f.Name }}     --> README.md (string)
   26 {{ $f.Size }}     --> 241 (int64)
   27 
   28 {{ $d := os.Stat "content" }}
   29 {{ $d.IsDir }}    --> true (bool)
   30 ```
   31 
   32 Details of the `FileInfo` structure are available in the [Go documentation](https://pkg.go.dev/io/fs#FileInfo).