package pflagimport// optional interface to indicate boolean flags that can be// supplied without "=value" texttype boolFlag interface {Value IsBoolFlag() bool}// -- bool Valuetype boolValue boolfunc newBoolValue( bool, *bool) *boolValue { * = return (*boolValue)()}func ( *boolValue) ( string) error { , := strconv.ParseBool() * = boolValue()return}func ( *boolValue) () string {return"bool"}func ( *boolValue) () string { returnstrconv.FormatBool(bool(*)) }func ( *boolValue) () bool { returntrue }func boolConv( string) (interface{}, error) {returnstrconv.ParseBool()}// GetBool return the bool value of a flag with the given namefunc ( *FlagSet) ( string) (bool, error) { , := .getFlagType(, "bool", boolConv)if != nil {returnfalse, }return .(bool), nil}// BoolVar defines a bool flag with specified name, default value, and usage string.// The argument p points to a bool variable in which to store the value of the flag.func ( *FlagSet) ( *bool, string, bool, string) { .BoolVarP(, , "", , )}// BoolVarP is like BoolVar, but accepts a shorthand letter that can be used after a single dash.func ( *FlagSet) ( *bool, , string, bool, string) { := .VarPF(newBoolValue(, ), , , ) .NoOptDefVal = "true"}// BoolVar defines a bool flag with specified name, default value, and usage string.// The argument p points to a bool variable in which to store the value of the flag.func ( *bool, string, bool, string) {BoolVarP(, , "", , )}// BoolVarP is like BoolVar, but accepts a shorthand letter that can be used after a single dash.func ( *bool, , string, bool, string) { := CommandLine.VarPF(newBoolValue(, ), , , ) .NoOptDefVal = "true"}// Bool defines a bool flag with specified name, default value, and usage string.// The return value is the address of a bool variable that stores the value of the flag.func ( *FlagSet) ( string, bool, string) *bool {return .BoolP(, "", , )}// BoolP is like Bool, but accepts a shorthand letter that can be used after a single dash.func ( *FlagSet) (, string, bool, string) *bool { := new(bool) .BoolVarP(, , , , )return}// Bool defines a bool flag with specified name, default value, and usage string.// The return value is the address of a bool variable that stores the value of the flag.func ( string, bool, string) *bool {returnBoolP(, "", , )}// BoolP is like Bool, but accepts a shorthand letter that can be used after a single dash.func (, string, bool, string) *bool { := CommandLine.BoolP(, , , )return}
The pages are generated with Goldsv0.8.2. (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds.