Clone this repo:
  1. 95d05c1 Prevent golang to set the non-block flag on ptmx open to avoid 100% CPU usage on reads (#53) by Guillaume J. Charmes · 6 weeks ago master v1.0.1
  2. 2c10821 Add mips64 mips64le build tags (#47) by Guillaume J. Charmes · 9 months ago v1.0.0
  3. 54a2d19 Add support for mips, mipsle (#45) by vstefanovic · 9 months ago
  4. ce7fa45 Merge pull request #44 from cmarcelo/pr/dragonfly-gofmt by Guillaume J. Charmes · 1 year, 4 months ago
  5. ed84cf8 Reformat pty_dragonfly.go file using gofmt by Caio Marcelo de Oliveira Filho · 1 year, 4 months ago

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