packer-cn/vendor/github.com/mattn/go-tty
Megan Marsh 53bbce4cd7 update to newest version of go-tty to fix control flow bug 2019-11-12 10:17:21 -08:00
..
.travis.yml add go-tty vendor 2019-02-27 17:01:02 +01:00
LICENSE add go-tty vendor 2019-02-27 17:01:02 +01:00
README.md add go-tty vendor 2019-02-27 17:01:02 +01:00
tty.go fix panic: send on closed channel 2019-04-25 10:49:08 +02:00
tty_bsd.go add go-tty vendor 2019-02-27 17:01:02 +01:00
tty_linux.go add go-tty vendor 2019-02-27 17:01:02 +01:00
tty_plan9.go fix panic: send on closed channel 2019-04-25 10:49:08 +02:00
tty_unix.go update to newest version of go-tty to fix control flow bug 2019-11-12 10:17:21 -08:00
tty_windows.go fix panic: send on closed channel 2019-04-25 10:49:08 +02:00

README.md

go-tty

Simple tty utility

Usage

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

Installation

$ go get github.com/mattn/go-tty

License

MIT

Author

Yasuhiro Matsumoto (a.k.a mattn)