Skip to content

Commit

Permalink
gofmt+fix ipv4 bare literal
Browse files Browse the repository at this point in the history
  • Loading branch information
James Hannah committed Aug 17, 2016
1 parent 4546675 commit cb4aeb9
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions ipgrep.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,18 @@ import (
)

func str2net(s string) (ipm *net.IPNet) {
if !strings.Contains(s, "/") {
s += "/32"
}
_,ipm,err := net.ParseCIDR(s)
if err != nil {
ipm = nil
}
return
if !strings.Contains(s, "/") {
if !strings.Contains(":") {
s += "/128"
} else {
s += "/32"
}
}
_, ipm, err := net.ParseCIDR(s)
if err != nil {
ipm = nil
}
return
}

type linelast struct {
Expand Down

0 comments on commit cb4aeb9

Please sign in to comment.