Essential Go Executing commands  Suggest an edit

os.Exec gotchas

exec.Cmd cannot be reused

An exec.Cmd cannot be reused after calling its Run, Output or CombinedOutput methods.

cmd := exec.Command("go", "version")
_, err := cmd.CombinedOutput()
if err != nil {
	log.Fatalf("first cmd.CombintedOutput() failed with '%s'\n", err)
}

_, err = cmd.CombinedOutput()
if err != nil {
	log.Fatalf("second cmd.CombintedOutput() failed with '%s'\n", err)
}
2018/10/18 02:25:05 second cmd.CombintedOutput() failed with 'exec: Stdout already set'
exit status 1
  ↑ ↓ to navigate     ↵ to select     Esc to close