I have a shell command (e.g. journalctl -f -o json
) that continuously streams lines to the standard output.
I would like to retrieve this output line by line and process it further.
The documentation of os/exec
addresses how to read the output of a command, and io
deals with stream buffering.
Everywhere I looked, the handling goes through a fixed buffer that is read into, handled, and written further. My problem is that the size of this buffer is fixed and independent of the content.
Is there a way to read an incoming stream (in my case - the output of a shell command) line by line? Possibly with a library more high-level than io
readers?