io

package
v0.37.1 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2021 License: GPL-2.0, GPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package io contains custom functions extending the native `io` package

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DuplicateReader

func DuplicateReader(reader systemio.Reader, errorCallback func(error)) (systemio.Reader, systemio.Reader)

DuplicateReader copies reads from a single io.Reader into a pair of io.Readers

It is the io.Reader analogue of an io.MultiWriter

func NewContinuousReader

func NewContinuousReader(reader systemio.Reader) systemio.Reader

NewContinuousReader creates a new ContinuousReader by wrapping an existing io.Reader

Types

type BellSkipper

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

BellSkipper is a custom WriteCloser that skips `Bell` characters

Used to prevent promptui making sounds when a button is pressed

func NewBellSkipper

func NewBellSkipper(baseOutput systemio.WriteCloser) *BellSkipper

NewBellSkipper creates a new BellSkipper WriteCloser

func (*BellSkipper) Close

func (skipper *BellSkipper) Close() error

Close closes the data stream

func (*BellSkipper) Write

func (skipper *BellSkipper) Write(b []byte) (int, error)

Write writes len(p) bytes from p to the underlying data stream.

type ContinuousReader

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

ContinuousReader is an io.Reader that wraps another reader and ignores io.EOF markers

This can be useful if you want to continue reading from a buffered reader after the buffer has been exhausted, for example

func (ContinuousReader) Read

func (reader ContinuousReader) Read(p []byte) (int, error)

NewContinuousReader creates a new ContinuousReader by wrapping an existing io.Reader

Read reads up to len(p) bytes into p. If an io.EOF error is returned by the underlying reader, it is silently ignored.

type ErrorReader added in v0.32.28

type ErrorReader struct {
}

func NewErrorReader added in v0.32.28

func NewErrorReader() *ErrorReader

func (*ErrorReader) Read added in v0.32.28

func (errorWriter *ErrorReader) Read(p []byte) (int, error)

type PipedWriteCloser added in v0.33.3

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

PipedWriteCloser is a simple struct that wraps an io.Pipe and a sync.WaitGroup for convenience

Use a PipedWriteCloser when a WriteCloser is expected by some interface and you need a simple way of reading all data written once the io.WriteCloser has been closed

func NewPipedWriteCloser added in v0.33.3

func NewPipedWriteCloser() *PipedWriteCloser

NewPipedWriteCloser creates a new PipedWriteCloser

The PipedWriteCloser will be ready to be written to and the sync.WaitGroup will be waiting for the io.WriteCloser to close, after which it will store the result and unblock any previous calls to Wait()

func (*PipedWriteCloser) Bytes added in v0.33.3

func (writeCloser *PipedWriteCloser) Bytes() []byte

Bytes returns all the data written to the writer as a slice of byte

If called before Wait(), the result is undefined

func (*PipedWriteCloser) Close added in v0.33.3

func (writeCloser *PipedWriteCloser) Close() error

Closer is the interface that wraps the basic Close method.

func (*PipedWriteCloser) String added in v0.33.3

func (writeCloser *PipedWriteCloser) String() string

Bytes returns all the data written to the writer as a string

If called before Wait(), the result is undefined

func (*PipedWriteCloser) Wait added in v0.33.3

func (writeCloser *PipedWriteCloser) Wait()

Wait blocks until the WaitGroup counter is zero.

func (*PipedWriteCloser) Write added in v0.33.3

func (writeCloser *PipedWriteCloser) Write(p []byte) (int, error)

Writer is the interface that wraps the basic Write method.

type SynchronizedBuffer added in v0.36.0

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

func NewSynchronizedBuffer added in v0.36.0

func NewSynchronizedBuffer() *SynchronizedBuffer

func (*SynchronizedBuffer) Bytes added in v0.36.0

func (syncBuffer *SynchronizedBuffer) Bytes() []byte

func (*SynchronizedBuffer) Read added in v0.36.0

func (syncBuffer *SynchronizedBuffer) Read(p []byte) (int, error)

func (*SynchronizedBuffer) String added in v0.36.0

func (syncBuffer *SynchronizedBuffer) String() string

func (*SynchronizedBuffer) Write added in v0.36.0

func (syncBuffer *SynchronizedBuffer) Write(p []byte) (int, error)

Jump to

Keyboard shortcuts

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