On Thu, Apr 11, 2019 at 10:57 AM hui zhang <fastfad...@gmail.com> wrote:
> How to resolve this ? If you're not using any options in your program, just the arguments, you may do this: $ cat main.go package main import ( "flag" "fmt" ) func main() { flag.Parse() fmt.Println(flag.NArg()) for i := 0; i < flag.NArg(); i++ { fmt.Println(flag.Arg(i)) } } $ cat all_test.go package main import ( "testing" ) func Test(t *testing.T) { main() } $ go test -coverprofile coverage.out -args 1 2 3 4 4 1 2 3 4 PASS coverage: 100.0% of statements ok tmp 0.001s $ -- 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. For more options, visit https://groups.google.com/d/optout.