Closed xhd2015 closed 2 months ago
The reason is that, when go emits test binary, the binary itself will invoke flag.Parse()
, which then will try to parse all flags on the command line, even when the program itself will parse these flags correctly.
To suppress this behavior, we just need to add a --
after -args
, which will then prevent flag.Parse()
from consuming the reminder args.
The following test:
When run with:
Will print a list of test flags like
-test.v
, along witha b c
.However, when run with
The program complains about
flag a provided but not defined