package pflagimport ()// -- net.IP valuetype ipValue net.IPfunc newIPValue( net.IP, *net.IP) *ipValue { * = return (*ipValue)()}func ( *ipValue) () string { returnnet.IP(*).String() }func ( *ipValue) ( string) error {if == "" {returnnil } := net.ParseIP(strings.TrimSpace())if == nil {returnfmt.Errorf("failed to parse IP: %q", ) } * = ipValue()returnnil}func ( *ipValue) () string {return"ip"}func ipConv( string) (interface{}, error) { := net.ParseIP()if != nil {return , nil }returnnil, fmt.Errorf("invalid string being converted to IP address: %s", )}// GetIP return the net.IP value of a flag with the given namefunc ( *FlagSet) ( string) (net.IP, error) { , := .getFlagType(, "ip", ipConv)if != nil {returnnil, }return .(net.IP), nil}// IPVar defines an net.IP flag with specified name, default value, and usage string.// The argument p points to an net.IP variable in which to store the value of the flag.func ( *FlagSet) ( *net.IP, string, net.IP, string) { .VarP(newIPValue(, ), , "", )}// IPVarP is like IPVar, but accepts a shorthand letter that can be used after a single dash.func ( *FlagSet) ( *net.IP, , string, net.IP, string) { .VarP(newIPValue(, ), , , )}// IPVar defines an net.IP flag with specified name, default value, and usage string.// The argument p points to an net.IP variable in which to store the value of the flag.func ( *net.IP, string, net.IP, string) {CommandLine.VarP(newIPValue(, ), , "", )}// IPVarP is like IPVar, but accepts a shorthand letter that can be used after a single dash.func ( *net.IP, , string, net.IP, string) {CommandLine.VarP(newIPValue(, ), , , )}// IP defines an net.IP flag with specified name, default value, and usage string.// The return value is the address of an net.IP variable that stores the value of the flag.func ( *FlagSet) ( string, net.IP, string) *net.IP { := new(net.IP) .IPVarP(, , "", , )return}// IPP is like IP, but accepts a shorthand letter that can be used after a single dash.func ( *FlagSet) (, string, net.IP, string) *net.IP { := new(net.IP) .IPVarP(, , , , )return}// IP defines an net.IP flag with specified name, default value, and usage string.// The return value is the address of an net.IP variable that stores the value of the flag.func ( string, net.IP, string) *net.IP {returnCommandLine.IPP(, "", , )}// IPP is like IP, but accepts a shorthand letter that can be used after a single dash.func (, string, net.IP, string) *net.IP {returnCommandLine.IPP(, , , )}
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.