Commit 4b6284a7 authored by Aaron Jacobs's avatar Aaron Jacobs Committed by Rob Pike

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/10740Reviewed-by: default avatarRob Pike <r@golang.org>
parent bbc4351e
...@@ -249,13 +249,14 @@ type Getter interface { ...@@ -249,13 +249,14 @@ type Getter interface {
Get() interface{} Get() interface{}
} }
// ErrorHandling defines how to handle flag parsing errors. // ErrorHandling defines how FlagSet.Parse behaves if the parse fails.
type ErrorHandling int type ErrorHandling int
// These constants cause FlagSet.Parse to behave as described if the parse fails.
const ( const (
ContinueOnError ErrorHandling = iota ContinueOnError ErrorHandling = iota // Return a descriptive error.
ExitOnError ExitOnError // Call os.Exit(2).
PanicOnError PanicOnError // Call panic with a descriptive error.
) )
// A FlagSet represents a set of defined flags. The zero value of a FlagSet // A FlagSet represents a set of defined flags. The zero value of a FlagSet
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment