...

Text file src/github.com/mattn/go-tty/README.md

Documentation: github.com/mattn/go-tty

     1# go-tty
     2
     3Simple tty utility
     4
     5## Usage
     6
     7```go
     8tty, err := tty.Open()
     9if err != nil {
    10	log.Fatal(err)
    11}
    12defer tty.Close()
    13
    14for {
    15	r, err := tty.ReadRune()
    16	if err != nil {
    17		log.Fatal(err)
    18	}
    19	// handle key event
    20}
    21```
    22
    23if you are on windows and want to display ANSI colors, use <a href="https://github.com/mattn/go-colorable">go-colorable</a>.
    24
    25```go
    26tty, err := tty.Open()
    27if err != nil {
    28	log.Fatal(err)
    29}
    30defer tty.Close()
    31
    32out := colorable.NewColorable(tty.Output())
    33
    34fmt.Fprintln(out, "\x1b[2J")
    35```
    36
    37## Installation
    38
    39```
    40$ go get github.com/mattn/go-tty
    41```
    42
    43## License
    44
    45MIT
    46
    47## Author
    48
    49Yasuhiro Matsumoto (a.k.a mattn)

View as plain text