Documentation ¶
Overview ¶
Package clios provides extensions to to the stdlib os package.
Index ¶
- Constants
- func Home(getenv func(string) string) (string, error)
- func ReadCloserForFilePath(stdin io.Reader, filePath string) (io.ReadCloser, error)
- func WriteCloserForFilePath(stdout io.Writer, filePath string) (io.WriteCloser, error)
- func XdgCacheHome(getenv func(string) string) (string, error)
- func XdgConfigHome(getenv func(string) string) (string, error)
- func XdgDataHome(getenv func(string) string) (string, error)
Constants ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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.