streams

package
v29.4.0-rc.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2026 License: Apache-2.0 Imports: 5 Imported by: 479

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type In

type In struct {
	// contains filtered or unexported fields
}

In is an input stream to read user input. It implements io.ReadCloser with additional utilities, such as putting the terminal in raw mode.

func NewIn

func NewIn(in io.ReadCloser) *In

NewIn returns a new In from an io.ReadCloser. If in is an *os.File, a reference is kept to the file, and accessible through In.File.

func (*In) CheckTty

func (i *In) CheckTty(attachStdin, ttyMode bool) error

CheckTty reports an error when stdin is requested for a TTY-enabled container, but the client stdin is not itself a terminal (for example, when input is piped or redirected).

func (*In) Close

func (i *In) Close() error

Close implements the io.Closer interface.

func (*In) FD

func (i *In) FD() uintptr

FD returns the file descriptor number for this stream.

func (*In) File

func (i *In) File() (*os.File, bool)

File returns the underlying *os.File if the stream was constructed from one. If the stream was created from a non-file (e.g., a pipe, buffer, or wrapper), the returned boolean will be false.

func (*In) IsTerminal

func (i *In) IsTerminal() bool

IsTerminal returns whether this stream is connected to a terminal.

func (*In) Read

func (i *In) Read(p []byte) (int, error)

Read implements the io.Reader interface.

func (*In) RestoreTerminal

func (i *In) RestoreTerminal()

RestoreTerminal restores the terminal state if SetRawTerminal succeeded earlier.

func (*In) SetIsTerminal

func (i *In) SetIsTerminal(isTerminal bool)

SetIsTerminal overrides whether a terminal is connected. It is used to override this property in unit-tests, and should not be depended on for other purposes.

func (*In) SetRawTerminal

func (i *In) SetRawTerminal() error

SetRawTerminal sets raw mode on the input terminal. It is a no-op if In is not a TTY, or if the "NORAW" environment variable is set to a non-empty value.

type Out

type Out struct {
	// contains filtered or unexported fields
}

Out is an output stream to write normal program output. It implements an io.Writer, with additional utilities for detecting whether a terminal is connected, getting the TTY size, and putting the terminal in raw mode.

func NewOut

func NewOut(out io.Writer) *Out

NewOut returns a new Out from an io.Writer. If out is an *os.File, a reference is kept to the file, and accessible through Out.File.

func (*Out) FD

func (o *Out) FD() uintptr

FD returns the file descriptor number for this stream.

func (*Out) File

func (o *Out) File() (*os.File, bool)

File returns the underlying *os.File if the stream was constructed from one. If the stream was created from a non-file (e.g., a pipe, buffer, or wrapper), the returned boolean will be false.

func (*Out) GetTtySize

func (o *Out) GetTtySize() (height uint, width uint)

GetTtySize returns the height and width in characters of the TTY, or zero for both if no TTY is connected.

func (*Out) IsTerminal

func (o *Out) IsTerminal() bool

IsTerminal returns whether this stream is connected to a terminal.

func (*Out) RestoreTerminal

func (o *Out) RestoreTerminal()

RestoreTerminal restores the terminal state if SetRawTerminal succeeded earlier.

func (*Out) SetIsTerminal

func (o *Out) SetIsTerminal(isTerminal bool)

SetIsTerminal overrides whether a terminal is connected. It is used to override this property in unit-tests, and should not be depended on for other purposes.

func (*Out) SetRawTerminal

func (o *Out) SetRawTerminal() error

SetRawTerminal puts the output of the terminal connected to the stream into raw mode.

On UNIX, this does nothing. On Windows, it disables LF -> CRLF/ translation. It is a no-op if Out is not a TTY, or if the "NORAW" environment variable is set to a non-empty value.

func (*Out) Write

func (o *Out) Write(p []byte) (int, error)

Write writes to the output stream.

Jump to

Keyboard shortcuts

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