hugo: Index | Files

package os

import ""

Package os provides template functions for interacting with the operating system.


Package Files

init.go os.go

type Namespace Uses

type Namespace struct {
    // contains filtered or unexported fields

Namespace provides template functions for the "os" namespace.

func New Uses

func New(d *deps.Deps) *Namespace

New returns a new instance of the os-namespaced template functions.

func (*Namespace) FileExists Uses

func (ns *Namespace) FileExists(i interface{}) (bool, error)

FileExists checks whether a file exists under the given path.

func (*Namespace) Getenv Uses

func (ns *Namespace) Getenv(key interface{}) (string, error)

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 Uses

func (ns *Namespace) ReadDir(i interface{}) ([]_os.FileInfo, error)

ReadDir lists the directory contents relative to the configured WorkingDir.

func (*Namespace) ReadFile Uses

func (ns *Namespace) ReadFile(i interface{}) (string, error)

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 Uses

func (ns *Namespace) Stat(i interface{}) (_os.FileInfo, error)

Stat returns the os.FileInfo structure describing file.

Package os imports 7 packages (graph) and is imported by 44 packages. Updated 2019-08-15. Refresh now. Tools for package owners.