package main
import (
"bytes"
"fmt"
"os/exec"
)
func main() {
cmd := exec.Command("dir")
var buf bytes.Buffer
cmd.Stdout = &buf
err := cmd.Start()
if err != nil {
fmt.Printf("error: %v\n", err)
}
err = cmd.Wait()
fmt.Printf("Command finished with error: %v\n", err)
fmt.Printf("Command finished with output: %v\n", buf.String())
}