rand

package
v7.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2020 License: BSD-3-Clause Imports: 8 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package rand implements cancelable reads from a cryptographically safe random number source.

Index

Constants

This section is empty.

Variables

Reader is a cryptographically safe random number source.

Functions

func Read

func Read(b []byte) (int, error)

Read blockingly reads from a random number source.

func ReadContext

func ReadContext(ctx context.Context, b []byte) (int, error)

ReadContext is a context-aware reader for random numbers.

Types

type ContextReader

type ContextReader interface {
	// Read behaves like a blocking io.Reader.Read.
	//
	// Read wraps ReadContext with a background context.
	Read(b []byte) (n int, err error)

	// ReadContext is an io.Reader that blocks until data is available or
	// until ctx is done.
	ReadContext(ctx context.Context, b []byte) (n int, err error)
}

ContextReader is a cancelable io.Reader.

func DefaultReaderWithContext

func DefaultReaderWithContext(ctx context.Context) ContextReader

DefaultReaderWithContext returns a context-aware io.Reader.

Because this stores the context, only use this in situations where an io.Reader is unavoidable.

Jump to

Keyboard shortcuts

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