os

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 9, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Namespace

type Namespace struct {
	// contains filtered or unexported fields
}

Namespace provides template functions for the "os" namespace.

func New

func New(ws Os) *Namespace

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

func (*Namespace) FileExists

func (ns *Namespace) FileExists(i any) (bool, error)

FileExists checks whether a file exists under the given path.

func (*Namespace) Getenv

func (ns *Namespace) Getenv(key any) (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

func (ns *Namespace) ReadDir(i any) ([]_os.FileInfo, error)

ReadDir lists the directory contents relative to the configured WorkingDir.

func (*Namespace) ReadFile

func (ns *Namespace) ReadFile(i any) (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

func (ns *Namespace) Stat(i any) (_os.FileInfo, error)

Stat returns the os.FileInfo structure describing file.

type Os

type Os interface {
	CheckAllowedGetEnv(name string) error
	WorkingDir() string

	WorkFs() afero.Fs
	Working() afero.Fs
	ContentFs() afero.Fs
	RelPathify(filename string, workingDir string) string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL