goflags

Double dash to stop flag parsing


I have seen several tools to utilize a double dash to stop interpreting command line arguments as flags.

Is there a way to do the same with the flags package from the standard library?

The reason is that my app is wrapping over another app and both have a -v flag to turn on verbose output.

I could simply change the flag definition for my app but I'm curious to know if this is doable with the standard library but something like this does not seem to be documented or simply does not exist.


Solution

  • Double dash to stop flag parsing

    I'm curious to know if this is doable with the standard library but something like this does not seem to be documented.


    Package flag

    import "flag"
    

    Flag parsing stops just before the first non-flag argument ("-" is a non-flag argument) or after the terminator "--".


    Read the documentation.