ioutil

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2024 License: MIT Imports: 4 Imported by: 1

Documentation

Overview

Package ioutil implements some I/O utility functions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReadRand added in v1.4.0

func ReadRand(r *rand.Rand, buf []byte) (n int, err error)

ReadRand read len(buf) bytes from *rand.Rand and writes them into buf. It always returns len(buf) and a nil error.

func SeekAndReadAll

func SeekAndReadAll(fi *os.File) ([]byte, error)

SeekAndReadAll reload file content without reopen the file. Usually used for Linux /proc pseudo-filesystem.

Types

type ProgressWriter added in v1.2.0

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

func NewProgressWriter added in v1.2.0

func NewProgressWriter(w io.Writer) *ProgressWriter

NewProgressWriter wraps io.Writer with total written size and a status channel.

func (*ProgressWriter) Close added in v1.2.0

func (pw *ProgressWriter) Close()

Close sends total written size to the blocking channel and then closes the channel. Only the sender should close a channel, never the receiver.

func (*ProgressWriter) Size added in v1.2.0

func (pw *ProgressWriter) Size() int

Size returns total written size of io.Writer.

func (*ProgressWriter) Status added in v1.2.0

func (pw *ProgressWriter) Status() chan int

Status returns the status channel. Total written size will be sent to the status channel without blocking after every write operation.

func (*ProgressWriter) Write added in v1.2.0

func (pw *ProgressWriter) Write(p []byte) (n int, err error)

Write implements the standard io.Writer interface.

func (*ProgressWriter) WriteString added in v1.2.0

func (pw *ProgressWriter) WriteString(s string) (n int, err error)

WriteString implements the standard io.StringWriter interface.

Jump to

Keyboard shortcuts

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