aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ip.go3
-rw-r--r--ip_test.go2
2 files changed, 4 insertions, 1 deletions
diff --git a/ip.go b/ip.go
index 3d414ba..06b8bcb 100644
--- a/ip.go
+++ b/ip.go
@@ -16,6 +16,9 @@ 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 {
+ if s == "" {
+ return nil
+ }
ip := net.ParseIP(strings.TrimSpace(s))
if ip == nil {
return fmt.Errorf("failed to parse IP: %q", s)
diff --git a/ip_test.go b/ip_test.go
index 1fec50e..7a5da10 100644
--- a/ip_test.go
+++ b/ip_test.go
@@ -24,7 +24,7 @@ func TestIP(t *testing.T) {
{"1.2.3.4", true, "1.2.3.4"},
{"127.0.0.1", true, "127.0.0.1"},
{"255.255.255.255", true, "255.255.255.255"},
- {"", false, ""},
+ {"", true, "0.0.0.0"},
{"0", false, ""},
{"localhost", false, ""},
{"0.0.0", false, ""},