gilo/terminal/io.go

30 lines
399 B
Go
Raw Normal View History

2021-03-24 16:23:17 -04:00
package terminal
import (
"bufio"
"fmt"
"os"
)
var reader = bufio.NewReader(os.Stdin)
func ReadKey() (rune, int) {
ch, size, err := reader.ReadRune()
if err != nil {
panic(err)
}
return ch, size
}
2021-03-26 16:18:03 -04:00
// Print string to stdout
func Write(s string, a ...interface{}) {
fmt.Printf(s, a...)
2021-03-25 13:20:33 -04:00
}
2021-03-26 16:18:03 -04:00
func WriteLn(s string, a ...interface{}) {
str := fmt.Sprintf(s, a...)
Write("%s\r\n", str)
2021-04-01 16:17:13 -04:00
}