1 // Copyright 2012 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
10 "github.com/spf13/pflag"
13 func ExampleShorthandLookup() {
17 pflag.BoolP(name, short, false, "verbose output")
19 // len(short) must be == 1
20 flag := pflag.ShorthandLookup(short)
22 fmt.Println(flag.Name)
25 func ExampleFlagSet_ShorthandLookup() {
29 fs := pflag.NewFlagSet("Example", pflag.ContinueOnError)
30 fs.BoolP(name, short, false, "verbose output")
32 // len(short) must be == 1
33 flag := fs.ShorthandLookup(short)
35 fmt.Println(flag.Name)