Handling Output from External Programs
The two external programs you’ve executed are well-behaved; if something goes wrong, they return an error that you can capture and use to make decisions. Unfortunately, not all programs work like that.
In some cases, the program exits with a successful return code even when something goes wrong. In these cases a message in STDOUT or STDERR generally provides details about the error condition. In other cases, a program completes successfully as designed but something on its output tells you that the condition represents an error.
When executing external programs in Go you can handle both of these scenarios by capturing the program’s output and parsing it to make decisions.
The next step in the pipeline ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access