pipe

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Pipe

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

Pipe is a goroutine-safe io.Reader/io.Writer pair. It's like io.Pipe except there are no PipeReader/PipeWriter halves, and the underlying buffer is an interface. (io.Pipe is always unbuffered)

func NewPipe

func NewPipe() *Pipe

func (*Pipe) BreakWithError

func (p *Pipe) BreakWithError(err error)

BreakWithError causes the next Read (waking up a current blocked Read if needed) to return the provided err immediately, without waiting for unread data.

func (*Pipe) CloseWithError

func (p *Pipe) CloseWithError(err error)

CloseWithError causes the next Read (waking up a current blocked Read if needed) to return the provided err after all data has been read.

The error must be non-nil.

func (*Pipe) Done

func (p *Pipe) Done() <-chan struct{}

Done returns a channel which is closed if and when this pipe is closed with CloseWithError.

func (*Pipe) Err

func (p *Pipe) Err() error

Err returns the error (if any) first set by BreakWithError or CloseWithError.

func (*Pipe) Len

func (p *Pipe) Len() int

func (*Pipe) Read

func (p *Pipe) Read(d []byte) (n int, err error)

Read waits until data is available and copies bytes from the buffer into p.

func (*Pipe) Write

func (p *Pipe) Write(d []byte) (n int, err error)

Write copies bytes from p into the buffer and wakes a reader. It is an error to write more data than the buffer can hold.

Jump to

Keyboard shortcuts

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