os.FileExists
Syntax
os.FileExists PATH
Returns
bool
Alias
fileExists
函数os.FileExists
尝试查找相对于项目目录根目录的路径。如果找不到匹配的文件或目录,则会尝试查找相对于contentDir
的路径。前缀路径分隔符(/
)是可选的。
具有以下目录结构:
content/
├── about.md
├── contact.md
└── news/
├── article-1.md
└── article-2.md
该函数返回以下值:
{{ fileExists "content" }} → true
{{ fileExists "content/news" }} → true
{{ fileExists "content/news/article-1" }} → false
{{ fileExists "content/news/article-1.md" }} → true
{{ fileExists "news" }} → true
{{ fileExists "news/article-1" }} → false
{{ fileExists "news/article-1.md" }} → true