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 ¶
- func DevNull() (string, error)
- func FilePathIsDevNull(filePath string) bool
- func FilePathIsStdin(filePath string) bool
- func FilePathIsStdout(filePath string) bool
- func ReadCloserForFilePath(stdin io.Reader, filePath string) (io.ReadCloser, error)
- func WriteCloserForFilePath(stdout io.Writer, filePath string) (io.WriteCloser, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FilePathIsDevNull ¶
FilePathIsDevNull returns true if the file path is the equivalent of /dev/null.
func FilePathIsStdin ¶
FilePathIsStdin returns true if filePath == "-".
func FilePathIsStdout ¶
FilePathIsStdout returns true if filePath == "-".
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 system error. If stdin is nil and filePath is "-", returns user 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 system error. If stdout is nil and filePath is "-", returns user error.
Types ¶
This section is empty.