input.go 454 B

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