周玉环 d906a41c2e first commit 2 天之前
..
.travis.yml d906a41c2e first commit 2 天之前
LICENSE d906a41c2e first commit 2 天之前
README.md d906a41c2e first commit 2 天之前
tty.go d906a41c2e first commit 2 天之前
tty_bsd.go d906a41c2e first commit 2 天之前
tty_linux.go d906a41c2e first commit 2 天之前
tty_plan9.go d906a41c2e first commit 2 天之前
tty_unix.go d906a41c2e first commit 2 天之前
tty_windows.go d906a41c2e first commit 2 天之前

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)