From b97c502b54ff0f5036cee90287de3af297faab01 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Sat, 6 Sep 2025 20:08:54 -0500 Subject: make Global. duh. --- questionUser.go | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 questionUser.go (limited to 'questionUser.go') diff --git a/questionUser.go b/questionUser.go new file mode 100644 index 0000000..3bba4ae --- /dev/null +++ b/questionUser.go @@ -0,0 +1,30 @@ +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 +} -- cgit v1.2.3