From af14497c6890cc90f0a3d191ae6acf628ed45c2c Mon Sep 17 00:00:00 2001 From: satotake Date: Sun, 9 Sep 2018 12:24:57 +0900 Subject: [PATCH] Add notes for `os.Stat` (Hugo 0.47) (#557) --- content/en/functions/os.Stat.md | 33 +++++++++++++++++++++++++++++++++ data/docs.json | 13 +++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 content/en/functions/os.Stat.md diff --git a/content/en/functions/os.Stat.md b/content/en/functions/os.Stat.md new file mode 100644 index 000000000..1e878d896 --- /dev/null +++ b/content/en/functions/os.Stat.md @@ -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 diff --git a/data/docs.json b/data/docs.json index 3ed3ab232..f13af5de3 100644 --- a/data/docs.json +++ b/data/docs.json @@ -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": [