mirror of
https://github.com/creack/pty.git
synced 2026-04-01 02:57:06 +09:00
2a896e26c7dee68a78d7e8639a566403df585b2c
pty
Pty is a Go package for using unix pseudo-terminals.
(Note, there is only a Linux implementation. I'd appreciate a patch for other systems!)
Install
go get github.com/kr/pty
Example
package main
import (
"fmt"
"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() {
fmt.Fprintln(f, "foo")
fmt.Fprintln(f, "bar")
fmt.Fprintln(f, "baz")
f.Close()
}()
io.Copy(os.Stdout, f)
c.Wait()
}
Languages
Go
93.4%
Shell
5.6%
Assembly
1%