Cmd.Start in Go

Posted by GoDoc
Public (Editable by Users)

Start starts the specified command but does not wait for it to complete.

Go
Edit
package main

import (
	"log"
	"os/exec"
)

func main() {
	cmd := exec.Command("sleep", "5")
	err := cmd.Start()
	if err != nil {
		log.Fatal(err)
	}
	log.Printf("Waiting for command to finish...")
	err = cmd.Wait()
	log.Printf("Command finished with error: %v", err)
}