mirror of
https://github.com/golang/go
synced 2024-11-27 03:31:29 -07:00
testing: comment out flag.Parse from example
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>
This commit is contained in:
parent
f7b2f58cda
commit
111064925b
@ -196,7 +196,7 @@
|
|||||||
// A simple implementation of TestMain is:
|
// A simple implementation of TestMain is:
|
||||||
//
|
//
|
||||||
// func TestMain(m *testing.M) {
|
// func TestMain(m *testing.M) {
|
||||||
// flag.Parse()
|
// // call flag.Parse() here if TestMain uses flags
|
||||||
// os.Exit(m.Run())
|
// os.Exit(m.Run())
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
|
Loading…
Reference in New Issue
Block a user