Hello,

I looked at the source and noticed that if I move the following line up two 
lines I guess basically what I'm looking for:

https://github.com/golang/go/blob/master/src/flag/flag.go#L874

But this is changing an unexported function. Is there a way to do something 
like this without messing with the source of standard library?

Cheers,
Thomas

On Sunday, December 8, 2019 at 12:00:44 PM UTC+1, Thomas Nyberg wrote:
>
> 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 needs an argument: -flagName
> Usage of ./flag_example:
>   -flagName string
>         Help message. (default "flagValue")
>
> What I would like to see is something like the following:
>
> $ ./flag_example -flagName
> Usage of ./flag_example:
>   -flagName string
>         Help message. (default "flagValue")
>
> flag needs an argument: -flagName
>
> In other words, I would like to move the error to the end. Is there an 
> easy way to achieve this? I know about changing Usage, but that doesn't 
> seem to affect this specific issue. Thanks for any help!
>
> Cheers,
> Thomas
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/6cbb4d2a-feb4-4396-8e60-6b8c92684c18%40googlegroups.com.

Reply via email to