mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-21 21:35:28 +02:00
Merge commit '9b0050e9aabe4be65c78ccf292a348f309d50ccd' as 'docs'
``` git subtree add --prefix=docs/ https://github.com/gohugoio/hugoDocs.git master --squash ``` Closes #11925
This commit is contained in:
31
docs/content/en/functions/os/Stat.md
Normal file
31
docs/content/en/functions/os/Stat.md
Normal file
@@ -0,0 +1,31 @@
|
||||
---
|
||||
title: os.Stat
|
||||
description: Returns a FileInfo structure describing a file or directory.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
aliases: []
|
||||
related:
|
||||
- functions/os/FileExists
|
||||
- functions/os/Getenv
|
||||
- functions/os/ReadDir
|
||||
- functions/os/ReadFile
|
||||
returnType: os.FileInfo
|
||||
signatures: [os.Stat PATH]
|
||||
aliases: [/functions/os.stat]
|
||||
---
|
||||
|
||||
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`](/getting-started/configuration#contentdir). A leading path separator (`/`) is optional.
|
||||
|
||||
```go-html-template
|
||||
{{ $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](https://pkg.go.dev/io/fs#FileInfo).
|
Reference in New Issue
Block a user