From faeb9df79237dc767cfe1f40af14e62c40a01ccd Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Sat, 4 Oct 2025 15:29:55 -0500 Subject: get input from STDIN --- questionUser.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/questionUser.go b/questionUser.go index c212334..f60ebd7 100644 --- a/questionUser.go +++ b/questionUser.go @@ -32,3 +32,22 @@ func QuestionUser(msg string) bool { } 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 "" +} -- cgit v1.2.3