streams

package
v0.0.0-...-bbc9ce3 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2021 License: BSD-2-Clause Imports: 3 Imported by: 0

Documentation

Overview

Package streams provides a mockable wrapper for `os.Stdout` and `os.Stderr`.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContextWithStderr

func ContextWithStderr(ctx context.Context, s io.Writer) context.Context

ContextWithStderr overrides os.Stderr for all code that uses the returned context, as long as it accesses stderr using `streams.Stderr(ctx)` instead of using `os.Stderr` directly.

This should only be used in tests; production code should never override os.Stderr.

func ContextWithStdout

func ContextWithStdout(ctx context.Context, s io.Writer) context.Context

ContextWithStdout overrides os.Stdout for all code that uses the returned context, as long as it accesses stdout using `streams.Stdout(ctx)` instead of using `os.Stdout` directly.

This should only be used in tests; production code should never override os.Stdout.

func Stderr

func Stderr(ctx context.Context) io.Writer

Stderr returns os.Stderr or the mocked stderr writer associated with the given context.

Use this function in code where you want to test what it writes to os.Stderr.

func Stdout

func Stdout(ctx context.Context) io.Writer

Stdout returns os.Stdout or the mocked stdout writer associated with the given context.

Use this function in code where you want to test what it writes to os.Stdout.

Types

This section is empty.

Jump to

Keyboard shortcuts

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