Gut on Windows can't get any input
julien040 opened this issue · comments
Describe the bug
On Windows, gut
can't be used because you can't pass the telemetry consent.
It keeps asking "please enter either y or n".
Expected behavior
Entering "y" should be accounted by gut. Now, it seems like gut receives another input than the one sent
Desktop (please complete the following information):
- OS: Windows 11
Possible reason
This is the function that reads an input for gut.
func InputLine(message string) (string, error) {
fmt.Printf("%s ", message)
reader := bufio.NewReader(os.Stdin)
input, err := reader.ReadString('\n')
if err != nil {
return "", err
}
// Remove the delimiter
return strings.TrimSuffix(input, "\n"), nil
}
At the end, it returns the input with \n
being omitted because it's added when the user enters to submit.
However, windows
doesn't end lines with \n
but with \r\n
.
It means gut
sees y\r
rather than y
.
In the next PR, I will add platform specific code to handle this case