I am trying to run a simple golang code
$ cat blah.go
package main
import (
"fmt"
"os/exec"
)
func main() {
cmd := exec.Command("sudo","ls")
out, err := cmd.Output()
fmt.Printf("%s", string(out))
fmt.Printf("%s", err.Error())
}
I am getting:
$ go run blah.go
blah.go
utils.go
weave_help_test.go
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x20 pc=0x400dc1]
goroutine 1 [running]:
runtime.panic(0x4b32a0, 0x5b1fc8)
/usr/lib/go/src/pkg/runtime/panic.c:266 +0xb6
main.main()
/home/Abhishek/go/src/github.com/blah.go:12 +0x1c1
exit status 2
How should I debug it?
$ go version
go version go1.2.1 linux/amd64