Add notes for os.Stat (Hugo 0.47) (#557)

This commit is contained in:
satotake 2018-09-09 12:24:57 +09:00 committed by Kaushal Modi
parent e49f65bb3c
commit af14497c68
2 changed files with 46 additions and 0 deletions

View File

@ -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

View File

@ -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": [