package os
import "github.com/gohugoio/hugo/tpl/os"
Package os provides template functions for interacting with the operating system.
Index ¶
- type Namespace
- func New(d *deps.Deps) *Namespace
- func (ns *Namespace) FileExists(i any) (bool, error)
- func (ns *Namespace) Getenv(key any) (string, error)
- func (ns *Namespace) ReadDir(i any) ([]_os.FileInfo, error)
- func (ns *Namespace) ReadFile(i any) (string, error)
- func (ns *Namespace) Stat(i any) (_os.FileInfo, error)
Types ¶
type Namespace ¶
type Namespace struct {
// contains filtered or unexported fields
}
Namespace provides template functions for the "os" namespace.
func New ¶
New returns a new instance of the os-namespaced template functions.
func (*Namespace) FileExists ¶
FileExists checks whether a file exists under the given path.
func (*Namespace) Getenv ¶
Getenv retrieves the value of the environment variable named by the key. It returns the value, which will be empty if the variable is not present.
func (*Namespace) ReadDir ¶
ReadDir lists the directory contents relative to the configured WorkingDir.
func (*Namespace) ReadFile ¶
ReadFile reads the file named by filename relative to the configured WorkingDir. It returns the contents as a string. There is an upper size limit set at 1 megabytes.
func (*Namespace) Stat ¶
Stat returns the os.FileInfo structure describing file.
Source Files ¶
- Version
- v0.144.2 (latest)
- Published
- Feb 19, 2025
- Platform
- linux/amd64
- Imports
- 11 packages
- Last checked
- 7 hours ago –
Tools for package owners.