osutil

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2019 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package osutil provides extensions to to the stdlib os package.

It primary interprets "-" as stdin or stdout, and the os-independent version of /dev/null

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DevNull

func DevNull() (string, error)

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

func FilePathIsDevNull

func FilePathIsDevNull(filePath string) bool

FilePathIsDevNull returns true if the file path is the equivalent of /dev/null.

func FilePathIsStdin

func FilePathIsStdin(filePath string) bool

FilePathIsStdin returns true if filePath == "-".

func FilePathIsStdout

func FilePathIsStdout(filePath string) bool

FilePathIsStdout returns true if filePath == "-".

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 system error. If stdin is nil and filePath is "-", returns user 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 system error. If stdout is nil and filePath is "-", returns user error.

Types

This section is empty.

Jump to

Keyboard shortcuts

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