package main import ( "os/exec" "strings" ) func main() { // None of these produce output: cmd := exec.Command("go", "list", "-json", "all") //cmd := exec.Command("cmd", "/c", "dir /s /b C:\\ ") // BTW, this doesn't work. Maybe that's okay: //cmd := exec.Command("cmd", "/c", "dir /s /b C:\\") // this works if your cwd is a small directory //cmd := exec.Command("cmd", "/c", "dir /s /b") out, err := cmd.Output() if err != nil { panic(err) } println(strings.TrimSpace(string(out))) }