Re: [go-nuts] Reordering error output in flags package so Usage is printed before the error?

2019-12-08 Thread andrey mirtchovski
You'll need to create a FlagSet instead and pass ContinueOnError as the error handling. If .Parse() returns an error call .PrintDefaults(), then print the error. On Sun, Dec 8, 2019 at 4:00 AM Thomas Nyberg wrote: > > Hello, > > Given the following file `flag_example.go`: > > package main > >

[go-nuts] Reordering error output in flags package so Usage is printed before the error?

2019-12-08 Thread Thomas Nyberg
Hello, Given the following file `flag_example.go`: package main import "flag" func main() { flagName := flag.String("flagName", "flagValue", "Help message.") flag.Parse() _ = flagName } If I execute it with a bad flag passed I see the following: $ ./flag_example -flagName flag