commit | 3b1c6581cb38cfd418c2051087c0a56a19d2c23a | [log] [tgz] |
---|---|---|
author | Keith Rarick <kr@xph.us> | Wed Feb 01 21:41:44 2012 -0800 |
committer | Keith Rarick <kr@xph.us> | Wed Feb 01 21:41:44 2012 -0800 |
tree | 42aacda66c397069c60310829d181336616d3424 | |
parent | 9e03abc5be1268ac16a690a5b054277751aaced8 [diff] |
go fmt
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!)
goinstall github.com/kr/pty
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) }