Cmd.Run in Go

Posted by GoDoc
Public (Editable by Users)

Run starts the specified command and waits for it to complete.

Go
Edit
package main

import (
	"log"
	"os/exec"
)

func main() {
	cmd := exec.Command("sleep", "1")
	log.Printf("Running command and waiting for it to finish...")
	err := cmd.Run()
	log.Printf("Command finished with error: %v", err)
}