gnormal / gnorm

A database-first code generator for any language
https://gnorm.org
Other
488 stars 40 forks source link

Running gnorm init causes panic #53

Closed wadtech closed 6 years ago

wadtech commented 6 years ago

When I run gnorm init in my directory, it panics about creating the gnorm.toml file.

Can't create gnorm.toml file: %!v(PANIC=runtime error: invalid memory address or nil pointer dereference)

Though the file is successfully created. It does however prevent the templates from being generated so I can't continue to use the tool.

Full trace:

peter@pete-thinkpad ~/projects/gnorm-sandbox % gnorm init
Can't create gnorm.toml file: %!v(PANIC=runtime error: invalid memory address or nil pointer dereference)
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0x7103db]

goroutine 1 [running]:
gnorm.org/gnorm/cli.(*codeErr).Error(0xc4200dcf00, 0xc4200d07c0, 0xc4200d8060)
    <autogenerated>:1 +0x3b
gnorm.org/gnorm/cli.(*codeErr).Error(0xc4200dcf20, 0x9815f8, 0x0)
    <autogenerated>:1 +0x49
gnorm.org/gnorm/vendor/github.com/spf13/cobra.(*Command).ExecuteC(0xc4200e8240, 0xc4200cfe60, 0xc4200d28d0, 0x0)
    /home/peter/projects/go/src/gnorm.org/gnorm/vendor/github.com/spf13/cobra/command.go:741 +0x4b7
gnorm.org/gnorm/vendor/github.com/spf13/cobra.(*Command).Execute(0xc4200e8240, 0xc4200cfe58, 0x1)
    /home/peter/projects/go/src/gnorm.org/gnorm/vendor/github.com/spf13/cobra/command.go:688 +0x2b
gnorm.org/gnorm/cli.ParseAndRun(0xc4200d0660, 0x1, 0x1, 0x9434a0, 0xc42000e020, 0x9434a0, 0xc42000e018, 0x943460, 0xc42000e010, 0xc4200d28d0, ...)
    /home/peter/projects/go/src/gnorm.org/gnorm/cli/run.go:56 +0x37c
gnorm.org/gnorm/cli.Run(0xc4200001a0)
    /home/peter/projects/go/src/gnorm.org/gnorm/cli/run.go:23 +0x1f4
main.main()
    /home/peter/projects/go/src/gnorm.org/gnorm/main.go:24 +0x22

Thanks

natefinch commented 6 years ago

Yikes! Thanks for the report. I'll have a fix up shortly. FYI, the templates that get generated are extremely minimal. They're really just there as placeholders for your own templates.

natefinch commented 6 years ago

This is fixed now, please pull down the newest code and try it again.

wadtech commented 6 years ago

Thanks very much, I'll try it out