2019-10-21 04:22:28 -04:00
---
title: os.Stat
2021-12-08 02:42:31 -05:00
description: Returns a FileInfo structure describing a file or directory.
2023-12-04 09:14:18 -05:00
categories: []
2023-10-20 03:42:39 -04:00
keywords: []
2023-12-04 09:14:18 -05:00
action:
2023-10-20 03:42:39 -04:00
aliases: []
2023-12-04 09:14:18 -05:00
related:
- functions/os/FileExists
- functions/os/Getenv
- functions/os/ReadDir
- functions/os/ReadFile
returnType: os.FileInfo
2023-10-20 03:42:39 -04:00
signatures: [os.Stat PATH]
aliases: [/functions/os.stat]
2019-10-21 04:22:28 -04:00
---
2023-10-20 03:42:39 -04:00
2023-05-22 10:43:12 -04:00
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.
2019-10-21 04:22:28 -04:00
2021-12-08 02:42:31 -05:00
```go-html-template
{{ $f := os.Stat "README.md" }}
2023-08-07 04:35:12 -04:00
{{ $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)
2019-10-21 04:22:28 -04:00
2021-12-08 02:42:31 -05:00
{{ $d := os.Stat "content" }}
2023-08-07 04:35:12 -04:00
{{ $d.IsDir }} → true (bool)
2021-12-08 02:42:31 -05:00
```
2019-10-21 04:22:28 -04:00
2021-12-08 02:42:31 -05:00
Details of the `FileInfo` structure are available in the [Go documentation ](https://pkg.go.dev/io/fs#FileInfo ).