You want to capture the text result return by exec function. How to do that?

Solution:

The code example below demonstrates how to capture the text result returns by the os/exec function. What the code does is to prepare in advance a pipe(io.ReadCloser) first before executing the exec program to capture the standard output. Then the value will be stored(appended) in a string slice for display at the end of the program.

By Adam Ng

IF you gain some knowledge or the information here solved your programming problem. Please consider donating to the less fortunate or some charities that you like. Apart from donation, planting trees, volunteering or reducing your carbon footprint will be great too.