Add pty_unsupported.go file in order to allow projects to import the package and still compile on other os/arch
1 file changed
tree: 14b519e5292b73b96448e436488cfd0d1a5bbae6
  1. .gitignore
  2. doc.go
  3. License
  4. pty_darwin.go
  5. pty_freebsd.go
  6. pty_linux.go
  7. pty_unsupported.go
  8. README.md
  9. run.go
  10. util.go
README.md

pty

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

Install

go get github.com/kr/pty

Example

package main

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

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)
}