commit | 8cde54c52f115795400a74041e54404563fdfc7a | [log] [tgz] |
---|---|---|
author | Ivan Cheremisin <[email protected]> | Mon Jul 22 18:14:41 2024 |
committer | Ivan Cheremisin <[email protected]> | Mon Jul 22 21:53:17 2024 |
tree | 93de994b95ce1817b9fc6880d093cca356ec93a6 | |
parent | 9ff45591957ea589b7e5acd5f307af2ab3c1e158 [diff] |
fix read after close test
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)