initial commit
This commit is contained in:
21
readline.go
Normal file
21
readline.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var rd *bufio.Reader
|
||||
|
||||
// ReadLine reads a line from stdin and strips newline from the end
|
||||
func ReadLine() string {
|
||||
if rd == nil {
|
||||
rd = bufio.NewReader(os.Stdin)
|
||||
}
|
||||
|
||||
str, err := rd.ReadString('\n')
|
||||
PanicOnError(err)
|
||||
|
||||
return strings.TrimRight(str, "\r\n")
|
||||
}
|
||||
Reference in New Issue
Block a user