gofix for release.r57.1
3 files changed
tree: 0d97a9a13678c5b8a35b928efb4b9cdc2b21f469
  1. .gitignore
  2. Makefile
  3. pty_darwin.go
  4. pty_linux.go
  5. README.md
  6. run.go
README.md

pty

Pty is a Go package for using unix pseudo-terminals.

(Note, the Darwin implementation doesn‘t work. If you are interested in fixing it, I’d appreciate a patch!)

Install

goinstall github.com/kr/pty

Example

package main

import (
    "fmt"
    "github.com/kr/pty"
    "io"
    "os"
)


func main() {
    c, err := pty.Run(
        "/bin/grep",
        []string{"grep", "--color=auto", "bar"},
        nil,
        "",
    )
    if err != nil {
        panic(err)
    }

    go func() {
        fmt.Fprintln(c.Stdin, "foo")
        fmt.Fprintln(c.Stdin, "bar")
        fmt.Fprintln(c.Stdin, "baz")
        c.Stdin.Close()
    }()
    io.Copy(os.Stdout, c.Stdout)
    c.Wait(0)
}