mark2web/vendor/github.com/mattn/go-tty
Sebastian Frank a781485c0a
Some checks failed
continuous-integration/drone/push Build is failing
no git submodules
2022-02-28 10:28:34 +01:00
..
.travis.yml no git submodules 2022-02-28 10:28:34 +01:00
go.mod no git submodules 2022-02-28 10:28:34 +01:00
go.sum no git submodules 2022-02-28 10:28:34 +01:00
LICENSE no git submodules 2022-02-28 10:28:34 +01:00
README.md no git submodules 2022-02-28 10:28:34 +01:00
tty_bsd.go no git submodules 2022-02-28 10:28:34 +01:00
tty_linux.go no git submodules 2022-02-28 10:28:34 +01:00
tty_plan9.go no git submodules 2022-02-28 10:28:34 +01:00
tty_solaris.go no git submodules 2022-02-28 10:28:34 +01:00
tty_unix.go no git submodules 2022-02-28 10:28:34 +01:00
tty_windows.go no git submodules 2022-02-28 10:28:34 +01:00
tty.go no git submodules 2022-02-28 10:28:34 +01:00

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)