Documentation ¶
Overview ¶
Package output provides a series of functions and structures to use to print text to outut devices. Since Device implements the io.Writer interface, it can be used for any Fprint statement.
Example ¶
var device = NewDevice(os.Stdout) fmt.Fprintln(device, "something") fmt.Fprintln(device, "something unpaused") device.Pause() fmt.Fprintln(device, "something paused") fmt.Fprintln(device, "something paused 2") fmt.Fprintln(device, "something paused 3") fmt.Println("== paused device ==") device.Resume()
Output: something something unpaused == paused device == something paused something paused 2 something paused 3
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Device ¶
type Device struct {
// contains filtered or unexported fields
}
Device masks an io.Writer with an intermediary buffer that receives the writes while the device is paused. Once the device is unpaused the masked io.Writer will receive the buffered writes.
Example ¶
var device = NewDevice(os.Stdout) device.Write([]byte("something\n")) device.Write([]byte("something unpaused\n")) device.Pause() device.Write([]byte("something paused\n")) device.Write([]byte("something paused 2\n")) device.Write([]byte("something paused 3\n")) fmt.Println("== paused device ==") device.Resume()
Output: something something unpaused == paused device == something paused something paused 2 something paused 3
func (*Device) Pause ¶
func (d *Device) Pause()
Pause pauses writes to the masked device and writes to an intermediary buffer.
func (*Device) Resume ¶
Resume copies the contents of the intermediary buffer to the device that is being masked.
func (*Device) Write ¶
Write writes len(p) bytes from p to the underlying data stream. It returns the number of bytes written from p (0 <= n <= len(p)) and any error encountered that caused the write to stop early. If the device is paused, instead of writing to the actual device it writes to an intermediary buffer that will hold any writes while the device is paused. If the device is paused for too long and causes the