Skip to content

Commit

Permalink
Add notes for os.Stat (Hugo 0.47) (#557)
Browse files Browse the repository at this point in the history
  • Loading branch information
satotake authored and kaushalmodi committed Sep 9, 2018
1 parent e49f65b commit af14497
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
33 changes: 33 additions & 0 deletions content/en/functions/os.Stat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
title: os.Stat
description: Gets a file information of a given path.
godocref:
date: 2018-08-07
publishdate: 2018-08-07
lastmod: 2018-08-07
categories: [functions]
menu:
docs:
parent: "functions"
keywords: [files]
signature: ["os.Stat PATH"]
workson: []
hugoversion:
relatedfuncs: [readDir]
deprecated: false
aliases: []
---

If your current project working directory has a single file named `README.txt` (30 bytes):
```
{{ $stat := os.Stat "README.txt" }}
{{ $stat.Name }} → "README.txt"
{{ $stat.Size }} → 30
```

Function [`os.Stat`][Stat] returns [`os.FileInfo`][osfileinfo].
For further information of `os.FileInfo`, see [golang page][osfileinfo].


[Stat]: /functions/os.Stat/
[osfileinfo]: https://golang.org/pkg/os/#FileInfo
13 changes: 13 additions & 0 deletions data/docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -2838,6 +2838,19 @@
}
},
"os": {
"Stat": {
"Description": "Stat returns a file infomation under the given path.",
"Args": [
"i"
],
"Aliases": null,
"Examples": [
[
"{{ (os.Stat \"foo.txt\").Name }}",
"foo.txt"
]
]
},
"FileExists": {
"Description": "FileExists checks whether a file exists under the given path.",
"Args": [
Expand Down

0 comments on commit af14497

Please sign in to comment.