aboutsummaryrefslogtreecommitdiff
path: root/src/flag
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2022-02-03 11:50:45 -0500
committerRuss Cox <rsc@golang.org>2022-03-15 17:17:30 +0000
commit1178255f8596ea503daf30c84c7c1039f755e7f0 (patch)
treee406084e097b7fe28b30213f19f1c6a68d01f88b /src/flag
parent9b112cec8363c0c574750d92cffe8682e80aacbe (diff)
downloadgo-1178255f8596ea503daf30c84c7c1039f755e7f0.tar.gz
go-1178255f8596ea503daf30c84c7c1039f755e7f0.zip
all: untab /* */ doc comments
A long time ago, gofmt insisted on inserting tabs in /* */ comments at the top level of the file, like this: /* Package doc comment. */ package p Gofmt still insists on the tab for comments not at top level, but it has relaxed the rules about top-level comments. A few very old doc comments are indented, left over from the old rule. We are considering formatting doc comments, and so to make everything consistent, standardize on unindented doc comments by removing tabs in the few doc comments that are still indented this way. Also update some cmd/gofmt testdata to match. Change-Id: I293742e39b52f8a48ec41f72ca4acdafa7ce43bc Reviewed-on: https://go-review.googlesource.com/c/go/+/384261 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/flag')
-rw-r--r--src/flag/flag.go116
1 files changed, 58 insertions, 58 deletions
diff --git a/src/flag/flag.go b/src/flag/flag.go
index c27a144434..cdea949a2f 100644
--- a/src/flag/flag.go
+++ b/src/flag/flag.go
@@ -3,67 +3,67 @@
// license that can be found in the LICENSE file.
/*
- Package flag implements command-line flag parsing.
+Package flag implements command-line flag parsing.
- Usage
+Usage
- Define flags using flag.String(), Bool(), Int(), etc.
+Define flags using flag.String(), Bool(), Int(), etc.
- This declares an integer flag, -n, stored in the pointer nFlag, with type *int:
- import "flag"
- var nFlag = flag.Int("n", 1234, "help message for flag n")
- If you like, you can bind the flag to a variable using the Var() functions.
- var flagvar int
- func init() {
- flag.IntVar(&flagvar, "flagname", 1234, "help message for flagname")
- }
- Or you can create custom flags that satisfy the Value interface (with
- pointer receivers) and couple them to flag parsing by
- flag.Var(&flagVal, "name", "help message for flagname")
- For such flags, the default value is just the initial value of the variable.
-
- After all flags are defined, call
- flag.Parse()
- to parse the command line into the defined flags.
-
- Flags may then be used directly. If you're using the flags themselves,
- they are all pointers; if you bind to variables, they're values.
- fmt.Println("ip has value ", *ip)
- fmt.Println("flagvar has value ", flagvar)
-
- After parsing, the arguments following the flags are available as the
- slice flag.Args() or individually as flag.Arg(i).
- The arguments are indexed from 0 through flag.NArg()-1.
-
- Command line flag syntax
-
- The following forms are permitted:
-
- -flag
- -flag=x
- -flag x // non-boolean flags only
- One or two minus signs may be used; they are equivalent.
- The last form is not permitted for boolean flags because the
- meaning of the command
- cmd -x *
- where * is a Unix shell wildcard, will change if there is a file
- called 0, false, etc. You must use the -flag=false form to turn
- off a boolean flag.
-
- Flag parsing stops just before the first non-flag argument
- ("-" is a non-flag argument) or after the terminator "--".
-
- Integer flags accept 1234, 0664, 0x1234 and may be negative.
- Boolean flags may be:
- 1, 0, t, f, T, F, true, false, TRUE, FALSE, True, False
- Duration flags accept any input valid for time.ParseDuration.
-
- The default set of command-line flags is controlled by
- top-level functions. The FlagSet type allows one to define
- independent sets of flags, such as to implement subcommands
- in a command-line interface. The methods of FlagSet are
- analogous to the top-level functions for the command-line
- flag set.
+This declares an integer flag, -n, stored in the pointer nFlag, with type *int:
+ import "flag"
+ var nFlag = flag.Int("n", 1234, "help message for flag n")
+If you like, you can bind the flag to a variable using the Var() functions.
+ var flagvar int
+ func init() {
+ flag.IntVar(&flagvar, "flagname", 1234, "help message for flagname")
+ }
+Or you can create custom flags that satisfy the Value interface (with
+pointer receivers) and couple them to flag parsing by
+ flag.Var(&flagVal, "name", "help message for flagname")
+For such flags, the default value is just the initial value of the variable.
+
+After all flags are defined, call
+ flag.Parse()
+to parse the command line into the defined flags.
+
+Flags may then be used directly. If you're using the flags themselves,
+they are all pointers; if you bind to variables, they're values.
+ fmt.Println("ip has value ", *ip)
+ fmt.Println("flagvar has value ", flagvar)
+
+After parsing, the arguments following the flags are available as the
+slice flag.Args() or individually as flag.Arg(i).
+The arguments are indexed from 0 through flag.NArg()-1.
+
+Command line flag syntax
+
+The following forms are permitted:
+
+ -flag
+ -flag=x
+ -flag x // non-boolean flags only
+One or two minus signs may be used; they are equivalent.
+The last form is not permitted for boolean flags because the
+meaning of the command
+ cmd -x *
+where * is a Unix shell wildcard, will change if there is a file
+called 0, false, etc. You must use the -flag=false form to turn
+off a boolean flag.
+
+Flag parsing stops just before the first non-flag argument
+("-" is a non-flag argument) or after the terminator "--".
+
+Integer flags accept 1234, 0664, 0x1234 and may be negative.
+Boolean flags may be:
+ 1, 0, t, f, T, F, true, false, TRUE, FALSE, True, False
+Duration flags accept any input valid for time.ParseDuration.
+
+The default set of command-line flags is controlled by
+top-level functions. The FlagSet type allows one to define
+independent sets of flags, such as to implement subcommands
+in a command-line interface. The methods of FlagSet are
+analogous to the top-level functions for the command-line
+flag set.
*/
package flag