From eeea8ce39cda3321d51c6cfe29fbcb2444fbf9cd Mon Sep 17 00:00:00 2001 From: Zeke Lu Date: Wed, 26 Oct 2022 07:05:44 +0800 Subject: [PATCH] flag: clarify that the main func at pkg.go.dev is part of a testing suite flag.Example() has this comment: ... one must execute, typically at the start of main (not init!): flag.Parse() We don't run it here because this is not a main function This example function will be renamed to "main" at pkg.go.dev, which makes the comment confusing. See https://pkg.go.dev/flag#example-package. This change modify the comment to clarify this situation. --- src/flag/example_test.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/flag/example_test.go b/src/flag/example_test.go index 76d8673306..088447d43f 100644 --- a/src/flag/example_test.go +++ b/src/flag/example_test.go @@ -78,7 +78,8 @@ func Example() { // to enable the flag package to see the flags defined there, one must // execute, typically at the start of main (not init!): // flag.Parse() - // We don't run it here because this is not a main function (it's renamed to - // "main" in playground, but bear in mind that this is a test example) and - // the testing suite has already parsed the flags. + // We don't call it here because this code is a function called "Example" + // that is part of the testing suite for the package, which has already + // parsed the flags. When viewed at pkg.go.dev, however, the function is + // renamed to "main" and it could be run as a standalone example. }