You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
go test -v ./ -args a b c
Will print a list of test flags like
-test.v
, along witha b c
.However, when run with
go test -v ./ -args -a b c
The program complains about
flag a provided but not defined
The text was updated successfully, but these errors were encountered: