The go language USES pipe to read the child process's standard output
- 2020-05-30 20:20:01
- OfStack
This article demonstrates an example of how the go language USES pipe to read the standard output of a child process. Share with you for your reference. The details are as follows:
Its core code is as follows:
cmd := exec.Command("cmd", "args")
stdout, err := cmd.StdoutPipe()
cmd.Start()
r := bufio.NewReader(stdout)
line, _, err := r.ReadLine()
I hope this article has been helpful to your programming of Go language.