Package list golang-github-sean--pager / e153c920-7f8f-4240-ae00-cdb3d3abb98e/main

Tree @e153c920-7f8f-4240-ae00-cdb3d3abb98e/main (Download .tar.gz)

# `pager`

Easy `$PAGER` support for Go (i.e. `less(1)`, `more(1)`) with sane defaults.

By default `pager` uses `less(1)` with the args: `-X -F -R --buffers=65535` and
sets `LESSSECURE=1` before starting `less(1)`.

If `less(1)` is unavailable, `pager` falls back to `more(1)`.

The `PAGER` environment variable is honored.

## Example Usage

import (


func main() {
  p, err := pager.New()
  if err != nil {
    panic(fmt.Sprintf("unable to get pager: %v", err))
  defer p.Wait()


func foo(w io.Writer) {
  fmt.Fprintf(w, "header\n")
  for i := 0; i < 1000; i++ {
    fmt.Fprintf(w, "line %03d\n", i)
  fmt.Fprintf(w, "trailer\n")

# Credit

Much of this was pulled from and reworked slightly.