mirror

package
v0.0.0-beta Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package mirror duplicates os.Stdout and os.Stderr to a file. ANSI escape sequences are stripped from the file copy, producing clean text.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Mirror

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

Mirror captures os.Stdout and os.Stderr writes and duplicates them to a file. The terminal gets raw bytes (with ANSI colors); the file gets stripped plain text. Create with New, close with Close to restore original descriptors.

func New

func New(path string) (*Mirror, error)

New creates a mirror that duplicates stdout and stderr to the file at path. The file is truncated on creation. ANSI escape sequences are stripped from the file copy so it contains clean, readable text. Call Close to restore original stdout/stderr and flush remaining output.

func (*Mirror) Close

func (m *Mirror) Close()

Close restores original stdout/stderr, flushes remaining pipe data, and closes the file.

func (*Mirror) OrigStdout

func (m *Mirror) OrigStdout() *os.File

OrigStdout returns the original os.Stdout that was captured before the mirror replaced it.

Jump to

Keyboard shortcuts

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