iohelpers

package
v3.11.7 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LazyReadCloser

func LazyReadCloser(open func() (io.ReadCloser, error)) io.ReadCloser

LazyReadCloser provides an interface to a ReadCloser that will open on the first access. The wrapped io.ReadCloser must be provided by 'open'.

func LazyWriteCloser

func LazyWriteCloser(open func() (io.WriteCloser, error)) io.WriteCloser

LazyWriteCloser provides an interface to a WriteCloser that will open on the first access. The wrapped io.WriteCloser must be provided by 'open'.

func NewEmptySkipper

func NewEmptySkipper(open func() (io.Writer, error)) io.WriteCloser

NewEmptySkipper creates an io.WriteCloser that will only start writing once a non-whitespace byte has been encountered. The wrapped io.WriteCloser must be provided by the `open` func.

func NormalizeFileMode added in v3.10.0

func NormalizeFileMode(mode os.FileMode) os.FileMode

NormalizeFileMode converts the given mode to a mode that will work as expected on the given OS. A no-op on non-Windows OSes, but on Windows modes work differently - only the owner read/write bits are honoured (i.e. the 0200 mask).

func SameSkipper

func SameSkipper(r io.Reader, open func() (io.WriteCloser, error)) io.WriteCloser

SameSkipper creates an io.WriteCloser that will only start writing once a difference with the current output has been encountered. The wrapped io.WriteCloser must be provided by 'open'.

Types

type NopCloser

type NopCloser struct {
	io.Writer
}

NopCloser returns a WriteCloser with a no-op Close method wrapping the provided io.Writer.

func (*NopCloser) Close

func (n *NopCloser) Close() error

Close - implements io.Closer

Jump to

Keyboard shortcuts

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