Good, that you found the problem yourself. I wasn't aware that you were on
Windows were newlines are represented by CRLF ("\r\n"). TrimSpace would
deal with that as well.
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this
I found the solution myself - when read in from stdin, there are 2 extra
characters - CR and LF. I just cut the string 2 characters before the end,
and it works! Thanks to those for posting replies!
On Thursday, August 24, 2017 at 11:35:31 PM UTC-4, Geoff Fridd wrote:
>
> Does anyone know why
ReadString returns the line including the terminating newline ('\n'). You
can check it with fmt.Printf("filename: %q\n", filename). One option to fix
it is using function strings.TrimSpace. It will remove all space characters
at the start and the end of the string.
--
You received this