package fhelp import ( "bufio" "fmt" "os" "strings" "go.wit.com/log" ) func QuestionUser(msg string) bool { log.Info("START", msg) fmt.Fprintf(os.Stdout, "(y)es or (n)o ? ") scanner := bufio.NewScanner(os.Stdin) for scanner.Scan() { log.Info("QUESTION USER SCAN", msg) line := scanner.Text() log.Info("QUESTION USER LINE", line) line = strings.TrimSpace(line) line = strings.ToLower(line) switch line { case "y": log.Info("QUESTION USER Y", msg) return true case "n": log.Info("QUESTION USER N", msg) return false default: log.Info("QUESTION USER DEFAULT", msg) if strings.HasPrefix(line, "y") { return true } return false } } log.Info("QUESTION USER END", msg) return false } func InputFromUser(msg string) string { log.Info(msg) fmt.Fprintf(os.Stdout, "") scanner := bufio.NewScanner(os.Stdin) for scanner.Scan() { line := scanner.Text() line = strings.TrimSpace(line) line = strings.ToLower(line) switch line { case "": continue default: return line } } return "" }