aboutsummaryrefslogtreecommitdiff
path: root/ip.go
diff options
context:
space:
mode:
authorEric Paris <[email protected]>2015-08-05 16:23:55 -0400
committerEric Paris <[email protected]>2015-08-05 19:30:09 -0400
commit30bf08c0d6db97cd5c95c4a9c5f826cfcec977f7 (patch)
treee4d9ed8f116f10a1c88364bcd941639519816195 /ip.go
parentc2a4060756151d538849fcfb494209d5315ec460 (diff)
Add _test for the net.IP flag type
Diffstat (limited to 'ip.go')
-rw-r--r--ip.go5
1 files changed, 4 insertions, 1 deletions
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)
}