Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FakeStdOutErr ¶
type FakeStdOutErr struct {
// contains filtered or unexported fields
}
modified from: https://eli.thegreenplace.net/2020/faking-stdin-and-stdout-in-go/
FakeStdio can be used to fake stdin and capture stdout. Between creating a new FakeStdio and calling ReadAndRestore on it, code reading os.Stdin will get the contents of stdinText passed to New. Output to os.Stdout will be captured and returned from ReadAndRestore. FakeStdio is not reusable; don't attempt to use it after calling ReadAndRestore, but it should be safe to create a new FakeStdio.
func New ¶
func New() (*FakeStdOutErr, error)
func (*FakeStdOutErr) ReadAndRestore ¶
func (sf *FakeStdOutErr) ReadAndRestore() ([]byte, []byte, error)
ReadAndRestore collects all captured stdout and returns it; it also restores os.Stdin and os.Stdout to their original values.
Click to show internal directories.
Click to hide internal directories.