pseudorand

package
v2.3.0-rc11 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2024 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Overview

this is a pseudorandom reader that generates a deterministic sequence of bytes based on the seed. It is used in tests to enable large volumes of pseudorandom data to be generated and compared without having to store the data in memory.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewSeed

func NewSeed() ([]byte, error)

NewSeed creates a new seed.

Types

type Reader

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

Reader is a pseudorandom reader that generates a deterministic sequence of bytes based on the seed.

func NewReader

func NewReader(seed []byte, l int) *Reader

New creates a new pseudorandom reader seeded with the given seed.

func (*Reader) Equal

func (r1 *Reader) Equal(r2 io.Reader) (bool, error)

Equal compares the contents of the reader with the contents of the given reader. It returns true if the contents are equal upto n bytes

func (*Reader) Match

func (r1 *Reader) Match(r2 io.Reader, l int) (bool, error)

Match compares the contents of the reader with the contents of the given reader. It returns true if the contents are equal upto n bytes

func (*Reader) Offset

func (r *Reader) Offset() int64

Offset returns the current offset of the reader.

func (*Reader) Read

func (r *Reader) Read(buf []byte) (n int, err error)

Read reads len(buf) bytes into buf. It returns the number of bytes read (0 <= n <= len(buf)) and any error encountered. Even if Read returns n < len(buf), it may use all of buf as scratch space during the call. If some data is available but not len(buf) bytes, Read conventionally returns what is available instead of waiting for more.

func (*Reader) ReadAt

func (r *Reader) ReadAt(buf []byte, off int64) (n int, err error)

ReadAt reads len(buf) bytes into buf starting at offset off.

func (*Reader) Seek

func (r *Reader) Seek(offset int64, whence int) (int64, error)

Seek sets the offset for the next Read to offset, interpreted according to whence: 0 means relative to the start of the file, 1 means relative to the current offset, and 2 means relative to the end. It returns the new offset and an error, if any.

func (*Reader) Size

func (r *Reader) Size() int

Size returns the size of the reader.

Jump to

Keyboard shortcuts

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