Read a string from stdin

This commit is contained in:
Timothy Warren 2021-03-25 13:20:33 -04:00
parent fdb34d8533
commit 0d5f2d0fcc

View File

@ -17,6 +17,17 @@ func ReadKey() (rune, int) {
return ch, size return ch, size
} }
func Read() (string, int) {
var buff []byte
size, err := reader.Read(buff)
if err != nil {
panic(err)
}
return string(buff), size
}
// Print string to stdout // Print string to stdout
func Write(s string) { func Write(s string) {
fmt.Print(s) fmt.Print(s)