codegangsta / gin

Live reload utility for Go web servers
MIT License
4.23k stars 317 forks source link

Unfriendly error when gin could not find go tool #124

Open pavel-odintsov opened 6 years ago

pavel-odintsov commented 6 years ago

Hello!

I spent some time to understand what's going on when tried to run gin from root user.

I got following error:

[gin] Listening on port 10007
[gin] Building...
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x6877f0]

goroutine 1 [running]:
github.com/codegangsta/gin/lib.(*builder).Build(0xc42007c480, 0xc4200552b0, 0x1)
    /home/odintsov/go/src/github.com/codegangsta/gin/lib/builder.go:62 +0x340
main.build(0x92aa20, 0xc42007c480, 0x92b760, 0xc42007c4e0, 0xc42007a3c0)
    /home/odintsov/go/src/github.com/codegangsta/gin/main.go:221 +0xcb
main.MainAction(0xc42009e840)
    /home/odintsov/go/src/github.com/codegangsta/gin/main.go:193 +0xa51
gopkg.in/urfave/cli%2ev1.HandleAction(0x72e3e0, 0x7bec10, 0xc42009e840, 0xc42007c400, 0x0)
    /home/odintsov/go/src/gopkg.in/urfave/cli.v1/app.go:492 +0x7c
gopkg.in/urfave/cli%2ev1.Command.Run(0x7aabe3, 0x3, 0x7aa91e, 0x1, 0x0, 0x0, 0x0, 0x7baa58, 0x32, 0x0, ...)
    /home/odintsov/go/src/gopkg.in/urfave/cli.v1/command.go:210 +0xb6e
gopkg.in/urfave/cli%2ev1.(*App).Run(0xc42006d380, 0xc42008e000, 0x9, 0x9, 0x0, 0x0)
    /home/odintsov/go/src/gopkg.in/urfave/cli.v1/app.go:255 +0x76f
main.main()
    /home/odintsov/go/src/github.com/codegangsta/gin/main.go:131 +0xd0d

Line 62 from gin's code:

if command.ProcessState.Success() {

I spent about 1 hour to find that I do not have "go" in PATH for the root user and then fixed the issue!

Could you add this check?

kwiesmueller commented 6 years ago

Getting the same error but can't find a solution