commit | 6cb1bbd1a001aa032786cfd3e90b8c1510a6621a | [log] [tgz] |
---|---|---|
author | Yasuhiro Matsumoto <[email protected]> | Mon Feb 19 16:04:51 2018 |
committer | Yasuhiro Matsumoto <[email protected]> | Mon Feb 19 16:04:51 2018 |
tree | a3c2e69b4c85ffccdd77b06d3321325fe03ed045 | |
parent | 70309ab5d2ae30846ef472a8c49fa0c8f2a450ef [diff] |
fix example
Simple tty utility
tty, err := tty.Open() if err != nil { log.Fatal(err) } defer tty.Close() for { r, err := tty.ReadRune() if err != nil { log.Fatal(err) } // handle key event }
if you are on windows and want to display ANSI colors, use go-colorable.
tty, err := tty.Open()
if err != nil {
log.Fatal(err)
}
defer tty.Close()
out := colorable.NewColorable(tty.Output())
fmt.Fprintln(out, "\x1b[2J")
$ go get github.com/mattn/go-tty
MIT
Yasuhiro Matsumoto (a.k.a mattn)