30 lines
399 B
Go
30 lines
399 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)
|
|
}
|