Debian Codegraph @

firestore/examples/end2end/src/userutil/readfromconsole.go

raw
1 package userutil
2
3 import (
4 "bufio"
5 "fmt"
6 "os"
7 "strings"
8 )
9
10 // ReadFromConsole ... Read user input from console
11 func ReadFromConsole() string {
12 reader := bufio.NewReader(os.Stdin)
13 text, err := reader.ReadString('\n')
14 text = strings.TrimSpace(text)
15
16 if err != nil {
17 fmt.Println(err)
18 return ""
19 }
20 return text
21
22 }