On Fri, May 26, 2017 at 1:32 PM, E Leong <[email protected]> wrote:
>
> I'm trying to pass arguments to go test using
>
> go test -args -flag1 val1 -flag2 val2
>
> Documentation doesn't explain how one can extract flag1 and flag2 or their
> values from within the test.
> I am using os.Args to get to them, but that feels like a hack.
>
> The only documentation I see right now in
> https://golang.org/cmd/go/#hdr-Description_of_testing_flags
>
> go test -v -args -x -v
>
>
> ... the -x and the second -v are passed through to the test binary unchanged
> and with no effect on the go command itself.

If you want your test program to have flags, use the flag package
(https://golang.org/pkg/flags) to define the flags you want.

Ian

-- 
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to