From 9b78e5b23ee478fda19010c124a89323cde15873 Mon Sep 17 00:00:00 2001 From: murdockq Date: Tue, 14 Nov 2017 11:22:27 -0500 Subject: [PATCH 1/2] Fix windows compatibility with command line '\r\n' The fix is to use ReadLine instead of ReadString('\n') since according to the documentation ReadLine trims both \r and \n from the line. --- quest.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/quest.go b/quest.go index ee59486..c1447cb 100644 --- a/quest.go +++ b/quest.go @@ -130,11 +130,11 @@ func (q *Question) wait() error { if q.choices { q.print(q.color("?"), " ", "Answer", " ") } - r, err := reader.ReadString('\n') + r, err := reader.ReadLine() if err != nil { return err } - q.response = r[:len(r)-1] + q.response = string(r) if abort := q.abort(q.response); abort.value != "" { abort.status = true return nil From ee1279fc383b65f6f441a5500b9c1c8f6bbff705 Mon Sep 17 00:00:00 2001 From: murdockq Date: Tue, 14 Nov 2017 11:36:34 -0500 Subject: [PATCH 2/2] Add missing return value. --- quest.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quest.go b/quest.go index c1447cb..e13b119 100644 --- a/quest.go +++ b/quest.go @@ -130,7 +130,7 @@ func (q *Question) wait() error { if q.choices { q.print(q.color("?"), " ", "Answer", " ") } - r, err := reader.ReadLine() + r, _, err := reader.ReadLine() if err != nil { return err }