go-flags icon indicating copy to clipboard operation
go-flags copied to clipboard

Using only positional arguments panics

Open chipaca opened this issue 7 years ago • 0 comments

I'm afraid I introduced a bug in fixing #278: now this

package main

import "github.com/jessevdk/go-flags"
import "os"

type options struct {
	Positional struct {
		Bar string `description:"bar"`
	} `positional-args:"yes"`
}

func main() {
	flags.NewParser(&options{}, 0).WriteHelp(os.Stdout)
}

crashes:

panic: strings: negative Repeat count

goroutine 1 [running]:
strings.Repeat(0x4ca350, 0x1, 0xfffffffffffffffe, 0x6, 0x0)
	/snap/go/2644/src/strings/strings.go:538 +0x1c7
github.com/jessevdk/go-flags.(*Parser).WriteHelp(0xc4200b4000, 0x4dd320, 0xc4200a8008)
	/home/john/canonical/snappy/src/github.com/jessevdk/go-flags/help.go:454 +0x511
main.main()
	/tmp/bug5.go:13 +0x6c
exit status 2

chipaca avatar Oct 10 '18 14:10 chipaca