aboutsummaryrefslogtreecommitdiff
path: root/example_test.go
diff options
context:
space:
mode:
authorAlex Ogier <[email protected]>2012-05-04 14:45:06 -0400
committerAlex Ogier <[email protected]>2012-05-04 14:45:06 -0400
commit123e81738a63da7f70f4b14c7d92586c9c317418 (patch)
treea47f24bee4afb2bb47a10b5b14538fcba71a5bc9 /example_test.go
parent0b6c6ef6fc716c5bcf32b085e782f99aff464755 (diff)
Fix up example for pflag
Diffstat (limited to 'example_test.go')
-rw-r--r--example_test.go17
1 files changed, 3 insertions, 14 deletions
diff --git a/example_test.go b/example_test.go
index fc3eb6c..f73e7cc 100644
--- a/example_test.go
+++ b/example_test.go
@@ -7,7 +7,7 @@ package pflag_test
import (
"errors"
- "flag"
+ flag "pflag"
"fmt"
"strings"
"time"
@@ -16,19 +16,8 @@ import (
// Example 1: A single string flag called "species" with default value "gopher".
var species = flag.String("species", "gopher", "the species we are studying")
-// Example 2: Two flags sharing a variable, so we can have a shorthand.
-// The order of initialization is undefined, so make sure both use the
-// same default value. They must be set up with an init function.
-var gopherType string
-
-func init() {
- const (
- defaultGopher = "pocket"
- usage = "the variety of gopher"
- )
- flag.StringVar(&gopherType, "gopher_type", defaultGopher, usage)
- flag.StringVar(&gopherType, "g", defaultGopher, usage+" (shorthand)")
-}
+// Example 2: A flag with a shorthand letter.
+var gopherType = flag.StringP("gopher_type", "g", "pocket", "the variety of gopher")
// Example 3: A user-defined flag type, a slice of durations.
type interval []time.Duration