stream

package
v0.0.0-...-c5cf874 Latest Latest
Warning

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

Go to latest
Published: May 20, 2024 License: MIT Imports: 4 Imported by: 7

Documentation

Overview

Package stream provides NullStream

Package stream defines input and output streams.

Index

Constants

This section is empty.

Variables

View Source
var Null io.ReadWriteCloser = nullStream{}

Null is an io.ReadWriteCloser.

Reads from it return 0 bytes and io.EOF. Writes and Closes succeed without doing anything.

See also io.Discard.

Functions

func IsNullWriter

func IsNullWriter(writer io.Writer) bool

IsNullWriter checks if a writer is known to be a writer that discards any input

Types

type IOStream

type IOStream struct {
	Stdin          io.Reader
	Stdout, Stderr io.Writer
}

IOStream represents a set of input and output streams commonly associated to a process.

func FromEnv

func FromEnv() IOStream

FromEnv creates a new IOStream using the environment.

The Stdin, Stdout and Stderr streams are used from the os package.

func FromNil

func FromNil() IOStream

FromNil creates a new IOStream that silences all output and provides no input.

func NewIOStream

func NewIOStream(Stdout, Stderr io.Writer, Stdin io.Reader) IOStream

NewIOStream creates a new IOStream with the provided readers and writers. If any of them are set to nil, they are set to Null.

func NonInteractive

func NonInteractive(Writer io.Writer) IOStream

NonInteractive creates a new non-interactive writer from a single output stream.

It is roughly equivalent to NewIOStream(Writer, Writer, nil, 0)

func (IOStream) EPrint

func (str IOStream) EPrint(args ...interface{}) (n int, err error)

EPrint is like fmt.Print but prints to str.Stderr.

func (IOStream) EPrintf

func (str IOStream) EPrintf(format string, args ...interface{}) (n int, err error)

EPrintf is like fmt.Printf but prints to io.Stderr.

func (IOStream) EPrintln

func (str IOStream) EPrintln(args ...interface{}) (n int, err error)

EPrintln is like fmt.Println but prints to io.Stderr.

func (IOStream) NonInteractive

func (str IOStream) NonInteractive() IOStream

NonInteractive creates a new IOStream with Null as standard input.

func (IOStream) Print

func (str IOStream) Print(args ...interface{}) (n int, err error)

Print is like fmt.Print but prints to str.Stdout.

func (IOStream) Printf

func (str IOStream) Printf(format string, args ...interface{}) (n int, err error)

Printf is like fmt.Printf but prints to str.Stdout.

func (IOStream) Println

func (str IOStream) Println(args ...interface{}) (n int, err error)

Println is like fmt.Println but prints to str.Stdout.

func (IOStream) ReadLine

func (str IOStream) ReadLine() (string, error)

ReadLine is like nobufio.ReadLine on the standard input

func (IOStream) ReadPassword

func (str IOStream) ReadPassword() (string, error)

ReadPassword is like nobufio.ReadPassword on the standard input

func (IOStream) ReadPasswordStrict

func (str IOStream) ReadPasswordStrict() (string, error)

ReadPasswordStrict is like nobufio.ReadPasswordStrict on the standard input

func (IOStream) StderrIsATerminal

func (str IOStream) StderrIsATerminal() bool

StderrIsATerminal checks if standard error is a terminal

func (IOStream) StdinIsATerminal

func (str IOStream) StdinIsATerminal() bool

StdinIsATerminal checks if standard input is a terminal

func (IOStream) StdoutIsATerminal

func (str IOStream) StdoutIsATerminal() bool

StdoutIsATerminal checks if standard output is a terminal

func (IOStream) Streams

func (str IOStream) Streams(Stdout, Stderr io.Writer, Stdin io.Reader, wrap int) IOStream

Streams creates a new IOStream with the provided streams. If any parameter is the zero value, copies the values from str.

Jump to

Keyboard shortcuts

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