package main
import (
"fmt"
"log"
"os/exec"
)
func main() {
out, err := exec.Command("date").Output()
if err != nil {
log.Fatal(err)
}
fmt.Printf("The date is %s\n", out)
}
This is a code example from the documentation for executing system commands. http://golang.org/pkg/os/exec/#example_Cmd_Output Even on the documentation site the example execute box doesn't run and has the same error: 2009/11/10 23:00:00 exec: "date": executable file not found in $PATH
On Windows I get: exec: "date": executable file not found in %PATH%
How do I get commands to work? Do I need to set a path or write out the full path of the command?