File: README.md

package info (click to toggle)
golang-github-mattn-go-tty 0.0.7-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, trixie
  • size: 128 kB
  • sloc: makefile: 3
file content (49 lines) | stat: -rw-r--r-- 626 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# 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 <a href="https://github.com/mattn/go-colorable">go-colorable</a>.

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