https://github.com/mattn/go-tty
https://github.com/mattn/go-tty
Last synced: 8 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/mattn/go-tty
- Owner: mattn
- License: mit
- Created: 2016-06-03T14:03:25.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2024-07-24T15:49:11.000Z (over 1 year ago)
- Last Synced: 2025-04-08T11:12:06.704Z (9 months ago)
- Language: Go
- Size: 87.9 KB
- Stars: 219
- Watchers: 11
- Forks: 18
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# go-tty
Simple tty utility
## Usage
```go
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.
```go
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)