New to Go and studying The Go Programming Language book, example chapter 1, dup2. I create a test file, test.txt with the following content:
harry
ron
hermione
ron
hagrid
dumbledore
harry
sneep
hermione
Running main.exe test.txt yields the expected output:
2 harry
2 ron
2 hermione
Running main.exe, entering the above content via the keyboard and ending with ctrl+c, typically misses one entry (not the same during several runs). Possible output:
2 ron
2 hermione
and
2 harry
2 ron
Is this expected behavior? (I’m working on Windows 10, installed go1.11.4.)
For me, if I run that program from the book linked here and Ctrl-C it, then I do see no further output at all. The program is just cancelled, and to be honest, I’d expect the same on windows.
If though I use Ctrl-D which is on linux used to send EOF, then I see the correct output every time.
As far as I remember, the windows equivalent of Ctrl-D is Ctrl-Z.