I have a Go binary file called "runme" that successfully runs like so:
./runme encrypt --password=password < plaintext.txt > encrypted.txt
It successfully reads in a file called "plaintext.txt" and outputs an encrypted file called "encrypted.txt".
Now I would like to use the dlv debugger for Go to debug it like so:
dlv exec ./runme -- encrypt -password=password < plaintext.txt > encrypted.txt
However I get the following error message from the dlv debugger:
Stdin is not a terminal, use '-r' to specify redirects for the target process or --allow-non-terminal-interactive=true if you really want to specify a redirect for Delve
So I try again slightly differently:
dlv exec -r ./runme -- encrypt -password=password < plaintext.txt > encrypted.txt
But I get the exact same error message shown above. Then I try the following:
dlv exec --allow-non-terminal-interactive=true ./runme -- encrypt -password=password < plaintext.txt > encrypted.txt
This time I get a different error message:
Command failed: command not available
What seems like a simple thing I am not able to do in the debugger. What could I be doing wrong?
With help from @tkausl and @gopher I was able to figure it out.
Solution is:
dlv exec -r stdin:plaintext.txt -r stdout:encrypted.txt ./runme -- encrypt -password=password