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

termtest

package
v0.0.14 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package termtest is a terminal for tests that run the program over a pipe: it takes what the program writes, as a terminal would, and says what the screen shows. The renderer writes only the cells that change between frames, so a word streamed over two frames is never whole in the bytes written; it is on the screen.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Term

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

Term is a terminal of a fixed size. Its Write is the program's output.

func New

func New(width, height int) *Term

New returns a terminal width columns wide and height rows tall. Close it when the program is done.

func (*Term) Close

func (t *Term) Close() error

Close ends the terminal's answers. It closes the pipe they are written to rather than the emulator, whose Close races its Read.

func (*Term) Raw

func (t *Term) Raw() string

Raw is every byte the program wrote, for what is a command to the terminal rather than something it shows (the clipboard, a mode).

func (*Term) Screen

func (t *Term) Screen() string

Screen is the text the screen shows, its trailing blanks trimmed.

func (*Term) Write

func (t *Term) Write(p []byte) (int, error)

Write takes the program's output. A newline is a carriage return and a line feed, as a terminal's line discipline makes it (ONLCR): a program whose input is not a terminal takes its output to be cooked, and moves the cursor to the start of a line below with a bare newline.

Jump to

Keyboard shortcuts

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