How can I call an external command in GO? I need to call an external program and wait for it to finish execution. before the next statement is executed.
package main import ( "fmt" "os/exec" "log" ) func main() { cmd := exec.Command("ls", "-ltr") out, err := cmd.CombinedOutput() if err != nil { log.Fatal(err) } fmt.Printf("%s\n", out) }
Try online