gilo/terminal/io.go
2021-03-26 16:18:03 -04:00

29 lines
398 B
Go

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
}
// Print string to stdout
func Write(s string, a ...interface{}) {
fmt.Printf(s, a...)
}
func WriteLn(s string, a ...interface{}) {
str := fmt.Sprintf(s, a...)
Write("%s\r\n", str)
}