From 123e81738a63da7f70f4b14c7d92586c9c317418 Mon Sep 17 00:00:00 2001 From: Alex Ogier Date: Fri, 4 May 2012 14:45:06 -0400 Subject: Fix up example for pflag --- example_test.go | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) (limited to 'example_test.go') 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 -- cgit v1.2.3