Documentation ¶
Overview ¶
Package rand implements cancelable reads from a cryptographically safe random number source.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Reader = DefaultReaderWithContext(context.Background())
Reader is a cryptographically safe random number source.
Functions ¶
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.
Click to show internal directories.
Click to hide internal directories.