github.com/lingyao2333/mo-zero@v1.4.1/core/cmdline/input.go (about) 1 package cmdline 2 3 import ( 4 "bufio" 5 "fmt" 6 "os" 7 "strings" 8 ) 9 10 // EnterToContinue let stdin waiting for an enter key to continue. 11 func EnterToContinue() { 12 fmt.Print("Press 'Enter' to continue...") 13 bufio.NewReader(os.Stdin).ReadBytes('\n') 14 } 15 16 // ReadLine shows prompt to stdout and read a line from stdin. 17 func ReadLine(prompt string) string { 18 fmt.Print(prompt) 19 input, _ := bufio.NewReader(os.Stdin).ReadString('\n') 20 return strings.TrimSpace(input) 21 }