Merge commit '5be51ac3db225d5df501ed1fa1499c41d97dbf65'

This commit is contained in:
Bjørn Erik Pedersen
2025-04-10 13:04:51 +02:00
987 changed files with 12379 additions and 14083 deletions

View File

@@ -3,19 +3,15 @@ title: os.FileExists
description: Reports whether the file or directory exists.
categories: []
keywords: []
action:
aliases: [fileExists]
related:
- functions/os/Getenv
- functions/os/ReadDir
- functions/os/ReadFile
- functions/os/Stat
returnType: bool
signatures: [os.FileExists PATH]
params:
functions_and_methods:
aliases: [fileExists]
returnType: bool
signatures: [os.FileExists PATH]
aliases: [/functions/fileexists]
---
The `os.FileExists` 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.
The `os.FileExists` 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`](/configuration/all/#contentdir). A leading path separator (`/`) is optional.
With this directory structure:

View File

@@ -3,17 +3,12 @@ title: os.Getenv
description: Returns the value of an environment variable, or an empty string if the environment variable is not set.
categories: []
keywords: []
action:
aliases: [getenv]
related:
- functions/os/FileExists
- functions/os/ReadDir
- functions/os/ReadFile
- functions/os/Stat
returnType: string
signatures: [os.Getenv VARIABLE]
params:
functions_and_methods:
aliases: [getenv]
returnType: string
signatures: [os.Getenv VARIABLE]
aliases: [/functions/getenv]
toc: true
---
## Security
@@ -30,9 +25,7 @@ To access other environment variables, adjust your site configuration. For examp
getenv = ['^HUGO_', '^CI$', '^USER$', '^HOME$']
{{< /code-toggle >}}
Read more about Hugo's [security policy].
[security policy]: /about/security/#security-policy
For more information see [configure security](/configuration/security).
## Examples

View File

@@ -3,15 +3,11 @@ title: os.ReadDir
description: Returns an array of FileInfo structures sorted by file name, one element for each directory entry.
categories: []
keywords: []
action:
aliases: [readDir]
related:
- functions/os/FileExists
- functions/os/Getenv
- functions/os/ReadFile
- functions/os/Stat
returnType: os.FileInfo
signatures: [os.ReadDir PATH]
params:
functions_and_methods:
aliases: [readDir]
returnType: os.FileInfo
signatures: [os.ReadDir PATH]
aliases: [/functions/readdir]
---

View File

@@ -3,19 +3,15 @@ title: os.ReadFile
description: Returns the contents of a file.
categories: []
keywords: []
action:
aliases: [readFile]
related:
- functions/os/FileExists
- functions/os/Getenv
- functions/os/ReadDir
- functions/os/Stat
returnType: string
signatures: [os.ReadFile PATH]
params:
functions_and_methods:
aliases: [readFile]
returnType: string
signatures: [os.ReadFile PATH]
aliases: [/functions/readfile]
---
The `os.ReadFile` function attempts to resolve the path relative to the root of your project directory. If a matching file is not found, it will attempt to resolve the path relative to the [`contentDir`](/getting-started/configuration#contentdir). A leading path separator (`/`) is optional.
The `os.ReadFile` function attempts to resolve the path relative to the root of your project directory. If a matching file is not found, it will attempt to resolve the path relative to the [`contentDir`](/configuration/all/#contentdir). A leading path separator (`/`) is optional.
With a file named README.md in the root of your project directory:

View File

@@ -3,19 +3,15 @@ title: os.Stat
description: Returns a FileInfo structure describing a file or directory.
categories: []
keywords: []
action:
aliases: []
related:
- functions/os/FileExists
- functions/os/Getenv
- functions/os/ReadDir
- functions/os/ReadFile
returnType: os.FileInfo
signatures: [os.Stat PATH]
params:
functions_and_methods:
aliases: []
returnType: os.FileInfo
signatures: [os.Stat PATH]
aliases: [/functions/os.stat]
---
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.
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`](/configuration/all/#contentdir). A leading path separator (`/`) is optional.
```go-html-template
{{ $f := os.Stat "README.md" }}

View File

@@ -1,12 +1,7 @@
---
title: OS functions
linkTitle: os
description: Template functions to interact with the operating system.
description: Use these functions to interact with the operating system.
categories: []
keywords: []
menu:
docs:
parent: functions
---
Use these functions to interact with the operating system.