aboutsummaryrefslogtreecommitdiff
path: root/src/flag
diff options
context:
space:
mode:
authorAaron Jacobs <jacobsa@google.com>2015-06-05 10:12:34 +1000
committerRob Pike <r@golang.org>2015-06-05 13:53:26 +0000
commit4b6284a7d918aa5813891bde2874411f29d5b418 (patch)
tree253e43b13227a76f50395c070a50f3464491ae08 /src/flag
parentbbc4351eca2ff435106566497cef0fa15566c42a (diff)
downloadgo-4b6284a7d918aa5813891bde2874411f29d5b418.tar.gz
go-4b6284a7d918aa5813891bde2874411f29d5b418.zip
flag: Describe the ErrorHandling enum values.
ContinueOnError is particularly confusing, because it causes FlagSet.Parse to return as soon as it sees an error. I gather that the intent is "continue the program" rather than "continue parsing", compared to exiting or panicking. Change-Id: I27370ce1f321ea4debcee5b03faff3532495c71a Reviewed-on: https://go-review.googlesource.com/10740 Reviewed-by: Rob Pike <r@golang.org>
Diffstat (limited to 'src/flag')
-rw-r--r--src/flag/flag.go9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/flag/flag.go b/src/flag/flag.go
index 060660248e..d1cb0a5ae6 100644
--- a/src/flag/flag.go
+++ b/src/flag/flag.go
@@ -249,13 +249,14 @@ type Getter interface {
Get() interface{}
}
-// ErrorHandling defines how to handle flag parsing errors.
+// ErrorHandling defines how FlagSet.Parse behaves if the parse fails.
type ErrorHandling int
+// These constants cause FlagSet.Parse to behave as described if the parse fails.
const (
- ContinueOnError ErrorHandling = iota
- ExitOnError
- PanicOnError
+ ContinueOnError ErrorHandling = iota // Return a descriptive error.
+ ExitOnError // Call os.Exit(2).
+ PanicOnError // Call panic with a descriptive error.
)
// A FlagSet represents a set of defined flags. The zero value of a FlagSet