From 30bf08c0d6db97cd5c95c4a9c5f826cfcec977f7 Mon Sep 17 00:00:00 2001 From: Eric Paris Date: Wed, 5 Aug 2015 16:23:55 -0400 Subject: Add _test for the net.IP flag type --- ip.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'ip.go') diff --git a/ip.go b/ip.go index 746eefd..baa442b 100644 --- a/ip.go +++ b/ip.go @@ -3,8 +3,11 @@ package pflag import ( "fmt" "net" + "strings" ) +var _ = strings.TrimSpace + // -- net.IP value type ipValue net.IP @@ -15,7 +18,7 @@ func newIPValue(val net.IP, p *net.IP) *ipValue { func (i *ipValue) String() string { return net.IP(*i).String() } func (i *ipValue) Set(s string) error { - ip := net.ParseIP(s) + ip := net.ParseIP(strings.TrimSpace(s)) if ip == nil { return fmt.Errorf("failed to parse IP: %q", s) } -- cgit v1.2.3