fhelp/questionUser.go

31 lines
431 B
Go

package fhelp
import (
"bufio"
"fmt"
"os"
"strings"
"go.wit.com/log"
)
func QuestionUser(msg string) bool {
log.Info(msg)
fmt.Fprintf(os.Stdout, "(y)es or (n)o ? ")
scanner := bufio.NewScanner(os.Stdin)
for scanner.Scan() {
line := scanner.Text()
line = strings.TrimSpace(line)
line = strings.ToLower(line)
switch line {
case "y":
return true
case "n":
return false
default:
}
}
return false
}