Help us shape the future of Go! Take the 2026 Go Developer Survey

fakeio

package
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2026 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FakedIO

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

FakedIO represents state of faking stdout/stderr/stdin. Restore() must be called finally to restore the state.

func Stderr

func Stderr() *FakedIO

Stderr starts to fake stderr and returns fakedIO object to restore input/output finally

func Stdin

func Stdin(in string) *FakedIO

Stdin sets given string as faked stdin input and returns fakedIO object to restore input/output finally

func StdinBytes

func StdinBytes(in []byte) *FakedIO

StdinBytes sets given bytes as faked stdin input and returns fakedIO object to restore input/output finally

func Stdout

func Stdout() *FakedIO

Stdout starts to fake stdout and returns fakedIO object to restore input/output finally

func (*FakedIO) Bytes

func (fake *FakedIO) Bytes() ([]byte, error)

Bytes returns buffer as []byte while faking stdout/stderr

func (*FakedIO) CloseStdin

func (fake *FakedIO) CloseStdin() *FakedIO

CloseStdin closes faked stdin

func (*FakedIO) Do

func (fake *FakedIO) Do(f func()) (string, error)

Do runs predicate f and returns output as string

func (*FakedIO) Err

func (fake *FakedIO) Err() error

Err returns error which occurred while setting faked stdin/stdout/stderr

func (*FakedIO) Read

func (fake *FakedIO) Read(p []byte) (int, error)

Read reads bytes from buffer while faking stdout/stderr

func (*FakedIO) Restore

func (fake *FakedIO) Restore()

Restore restores faked stdin/stdout/stderr. This must be called finally.

func (*FakedIO) Stderr

func (fake *FakedIO) Stderr() *FakedIO

Stderr replace stderr with faked output buffer

func (*FakedIO) Stdin

func (fake *FakedIO) Stdin(in string) *FakedIO

Stdin sets given string as faked input for stdin

func (*FakedIO) StdinBytes

func (fake *FakedIO) StdinBytes(in []byte) *FakedIO

StdinBytes sets input buffer for stdin with bytes

func (*FakedIO) Stdout

func (fake *FakedIO) Stdout() *FakedIO

Stdout replace stdout with faked output buffer

func (*FakedIO) String

func (fake *FakedIO) String() (string, error)

String returns buffer as string while faking stdout/stderr

Jump to

Keyboard shortcuts

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