PTY interface for Go
Pty is a Go package for using unix pseudo-terminals.
go get github.com/creack/ptyNote that those examples are for demonstration purpose only, to showcase how to use the library. They are not meant to be used in any kind of production environment.
package main
import (
"io"
"os"
"os/exec"
"github.com/creack/pty"
)
func main() {
c := exec.Command("grep", "--color=auto", "bar")
f, err := pty.Start(c)
if err != nil {
panic(err)
}
go func() {
f.Write([]byte("foo\n"))
f.Write([]byte("bar\n"))
f.Write([]byte("baz\n"))
f.Write([]byte{4}) // EOT
}()
io.Copy(os.Stdout, f)
}…No open issues yet, or sync has not completed.