Open jawher opened 4 years ago
Getting a panic.
Pulled this branch:
GO111MODULE=on go get github.com/jawher/mow.cli@issue-104-app-model
Here's a pared-down file that shows the issue:
package main
import (
"os"
"github.com/davecgh/go-spew/spew"
cli "github.com/jawher/mow.cli"
)
func main() {
app := cli.App("myapp", "Description.")
app.Version("version", "1")
app.Command("do", "Do the thing.", func(config *cli.Cmd) {})
spew.Dump(app.Model())
err = app.Run(os.Args)
if err != nil {
exitErrorf(err)
}
}
And the panic.
panic: runtime error: index out of range [0] with length 0
goroutine 1 [running]:
github.com/jawher/mow%2ecli.(*Cmd).Model(0xc00014e200, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
/path/to/gocode/pkg/mod/github.com/jawher/mow.cli@v1.1.1-0.20200703143524-5e525d076aa4/commands.go:157 +0xaec
github.com/jawher/mow%2ecli.(*Cmd).Model(0xc00014e100, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
/path/to/gocode/pkg/mod/github.com/jawher/mow.cli@v1.1.1-0.20200703143524-5e525d076aa4/commands.go:167 +0x9fc
github.com/jawher/mow%2ecli.(*Cli).Model(...)
/path/to/gocode/pkg/mod/github.com/jawher/mow.cli@v1.1.1-0.20200703143524-5e525d076aa4/cli.go:71
main.main()
/path/to/gocode/src/github.com/skyzyx/project/src/main.go:16 +0x197
I don't see anything obvious in the code other than commands.go:157
references make()
with a specific len
as the second parameter. Maybe it's miscalculating?
@skyzyx Nice catch ! I just pushed a commit to fix a bug in a slice allocation len 🤦♂️
Had a chance to come back to this, and I'm quite happy with the results. THANK YOU!
Ping
This is available on the master
branch, but has not been cut into a release.
app.Model()
Fixes #104