Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrNoCommand = errors.New("No pager command to execute.") ErrClosed = errors.New("The pager was closed.") )
Functions ¶
This section is empty.
Types ¶
type Pager ¶
type Pager struct {
// contains filtered or unexported fields
}
Pager spawns and lets users write to a pager program.
If an error occurs while writing to the pager, all subsequent writes, Close, and Error, will return that error.
It implements io.WriteCloser.
func Open ¶
Open calls OpenPager("", nil).
Example ¶
out, err := pager.Open() if err != nil { log.Fatal(err) } defer out.Close() out.Write([]byte("Hello, World!"))
Output: Hello, World!
func OpenPager ¶
OpenPager spawns the pager program from the passed command, redirecting its standard output to dst, and returns a new Pager object.
If command is an empty string, then the value of the PAGER enviroment variable is used instead. If it is also empty, then ErrNoCommand is returned. Any command is valid as long as they are acceptable as an operand to "sh -c".
If dst is nil, os.Stdout is used instead.
func (*Pager) Close ¶
Close closes the write end of the pager and frees all ressources associated with it. It returns the last write error that occured, or any error from the pager process.
func (*Pager) ReadFrom ¶
ReadFrom implements io.ReaderFrom. It is equivalent to a call to io.Copy using the underlying write end of the pager as destination.
func (*Pager) Write ¶
Write writes the contents of data into the pager, and returns the number of bytes written. If n < len(data), it also returns an error explaining why the write is short.
If Closed was previously called, or if the user closes the read end of the pager -- typically by exiting the pager program -- then Write returns the ErrClosed error.