]> Cypherpunks repositories - gostls13.git/commitdiff
testing: comment out flag.Parse from example
authorDaniel Martí <mvdan@mvdan.cc>
Wed, 16 Nov 2016 12:26:23 +0000 (12:26 +0000)
committerIan Lance Taylor <iant@golang.org>
Fri, 25 Nov 2016 16:41:34 +0000 (16:41 +0000)
The TestMain docs explain that flag.Parse() should be called if TestMain
itself depends on command-line flags.

The issue here is that the example implementation does not use any
flags, and thus the flag.Parse call is unnecessary. This leads to people
who use this example as a starting point for their own implementations
to forget that the call is not necessary in most cases.

Comment it out instead of removing the line to keep it as a reminder, as
suggested by Minux Ma.

Change-Id: I6ffc5413e7036366ae3cf0f069b7065e832a3b45
Reviewed-on: https://go-review.googlesource.com/33273
Reviewed-by: Minux Ma <minux@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/testing/testing.go

index 01f5da31d7179fd7a38c07be641749fd17321b01..f08c5c6b8e22f02c1b51ddcee3d5e77f59ef3c72 100644 (file)
 // A simple implementation of TestMain is:
 //
 //     func TestMain(m *testing.M) {
-//             flag.Parse()
+//             // call flag.Parse() here if TestMain uses flags
 //             os.Exit(m.Run())
 //     }
 //