utils

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: May 2, 2023 License: MIT Imports: 3 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Discard

func Discard(reader io.Reader) error

Discard the provided reader

func GetMultiWriter

func GetMultiWriter(writers ...io.Writer) io.Writer

GetMultiWriter returns a multiwriter composed of the provided valid writer (!= nil)

func MarshalUint32

func MarshalUint32(b []byte, v uint32)

MarshalUint32 writes the provided uint32 into the provided byte array Deprecated

func MarshalUint64

func MarshalUint64(b []byte, v uint64)

MarshalUint64 writes the provided uint64 into the provided byte array Deprecated

func NewVoidHash

func NewVoidHash() hash.Hash

NewVoidHash returns an empty implementation of hash.Hash which always returns an empty byte array

func UnmarshalUint32

func UnmarshalUint32(b []byte) (uint32, []byte)

UnmarshalUint32 retrieves an uint32 from the provided byte array Deprecated

Types

type LimitedReader

type LimitedReader struct {
	R io.Reader // underlying reader
	N int64     // max bytes remaining
}

LimitedReader reads from R but limits the amount of data returned to just N bytes. Each call to Read updates N to reflect the new amount remaining. Read returns EOF AS SOON AS N <= 0 or when the underlying R returns EOF.

func (*LimitedReader) Read

func (l *LimitedReader) Read(p []byte) (n int, err error)

type LockedReader

type LockedReader struct {
	R      io.Reader
	Unlock func()
	// contains filtered or unexported fields
}

LockedReader reads from R and call the Unlock function once R.Read() returns an error Read returns EOF when N <= 0 or when the underlying R returns EOF.

func (*LockedReader) Read

func (l *LockedReader) Read(buf []byte) (int, error)

type OffsetReader

type OffsetReader struct {
	R      io.ReaderAt
	Offset int64
}

OffsetReader wraps an io.WriterAt into an io.Writer

func (*OffsetReader) Read

func (o *OffsetReader) Read(buf []byte) (int, error)

type OffsetWriter

type OffsetWriter struct {
	W      io.WriterAt
	Offset int64
}

OffsetWriter wraps an io.WriterAt into an io.Writer

func (*OffsetWriter) Write

func (o *OffsetWriter) Write(buf []byte) (int, error)

type ReadWriterAt

type ReadWriterAt interface {
	io.ReaderAt
	io.WriterAt
}

ReadWriterAt is the interface that groups ReadAt and WriteAt methods.

Jump to

Keyboard shortcuts

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