clios

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2020 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package clios provides extensions to to the stdlib os package.

Index

Constants

View Source
const DevNull = "/dev/null"

DevNull is the equivalent of /dev/null for darwin, linux, and windows.

This will be /dev/null for darwin and linux. This will be nul for windows.

Variables

This section is empty.

Functions

func Home

func Home(getenv func(string) string) (string, error)

Home outputs the equivalent of $HOME for darwin, linux, and windows.

This will be $HOME for darwin and linux. This will be %HOMEDRIVE%%HOMEPATH% for windows, falling back to %USERPROFILE%.

func ReadCloserForFilePath

func ReadCloserForFilePath(stdin io.Reader, filePath string) (io.ReadCloser, error)

ReadCloserForFilePath returns an io.ReadCloser for the filePath.

If the filePath is "-", this is interpreted as stdin and stdin is returned. If the filePath is the equivalent of /dev/null, this returns a DiscardReader. If the filePath is "", this returns error. If stdin is nil and filePath is "-", returns error.

func WriteCloserForFilePath

func WriteCloserForFilePath(stdout io.Writer, filePath string) (io.WriteCloser, error)

WriteCloserForFilePath returns an io.WriteCloser for the filePath.

If the filePath is "-", this is interpreted as stdout and stdout is returned. If the filePath is the equivalent of /dev/null, this returns ioutil.Discard. If the filePath is "", this returns error. If stdout is nil and filePath is "-", returns error.

func XdgCacheHome

func XdgCacheHome(getenv func(string) string) (string, error)

XdgCacheHome returns the equivalent of $XDG_CACHE_HOME for darwin, linux, and windows.

This is suitable for a cache directory. https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html

This will be $XDG_CACHE_HOME for darwin and linux, falling back to $HOME/.cache. This will be %LOCALAPPDATA% for windows, falling back to $HOME/AppData/Local.

Users cannot assume that XDG_CONFIG_HOME, XDG_CACHE_HOME, and XDG_DATA_HOME are unique.

func XdgConfigHome

func XdgConfigHome(getenv func(string) string) (string, error)

XdgConfigHome returns the equivalent of $XDG_CONFIG_HOME for darwin, linux, and windows.

This is suitable for a configuration directory. https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html

This will be $XDG_CONFIG_HOME for darwin and linux, falling back to $HOME/.config. This will be %LOCALAPPDATA% for windows, falling back to $HOME/AppData/Local.

Users cannot assume that XDG_CONFIG_HOME, XDG_CACHE_HOME, and XDG_DATA_HOME are unique.

func XdgDataHome

func XdgDataHome(getenv func(string) string) (string, error)

XdgDataHome returns the equivalent of $XDG_DATA_HOME for darwin, linux, and windows.

This is suitable for a data directory. https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html

This will be $XDG_DATA_HOME for darwin and linux, falling back to $HOME/.local/share. This will be %LOCALAPPDATA% for windows, falling back to $HOME/AppData/Local.

Users cannot assume that XDG_CONFIG_HOME, XDG_CACHE_HOME, and XDG_DATA_HOME are unique.

Types

This section is empty.

Jump to

Keyboard shortcuts

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