Why do I get multiple times the same data?

I have recently added a ROT13 logic to a tool of mine.
This tool connects to a server, from which I run commands on the client.

Here is the code PRE-ROT13:
https://play.golang.org/p/DAE4cLq3RSx
Everything works like a charm.

Here is the code POST-ROT13. The difference between them is underlined
https://play.golang.org/p/DfFJSvuBx05

Both functions handle the output of the commands.

The ROT13 works fine, but I get the same output multiple time, which before did not happen. Infact, if I revert the changes, everything works perfectly.

Example:

$ whoami
$ xnyv
$ whoami
$ xnyv
xnyv
$ whoami
$ xnyv
xnyv
xnyv
$ whoami
$ xnyv
xnyv
xnyv
xnyv

Why do I get this result? How can I fix it?
May be fub’s fault? It is like if the output get cached somehow, but I may be wrong.

The problem is fub.
If I move fub inside the for cycle, I get correctly one time the output, but if I run a command like “cat /etc/passwd”, the tool explodes with this error:
panic: runtime error: index out of range [512] with length 512

For anyone that will have my same problem: the effective pain was fub. I had to empty fub after the for cycle with fub.Reset()

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.