Skip to content

Commit 22b12a7

Browse files
Show error message if IP address not valid
1 parent cb6bcaf commit 22b12a7

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

ip2locationio/ip2locationio.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ var myLanguage string
1515
var myIP string
1616
var filterFields string
1717

18-
const version string = "1.0.0"
18+
const version string = "1.0.1"
1919
const programName string = "IP2Location.io Command Line"
2020

2121
var showVer bool = false
@@ -70,8 +70,11 @@ func main() {
7070
} else if arg == "range2cidr" {
7171
PrintRange2CIDR(flag.Arg(1), flag.Arg(2))
7272
return
73-
} else if len(arg) == 0 || (!IsIPv4(arg) && !IsIPv6(arg)) {
73+
} else if len(arg) == 0 {
7474
myIP = MyPublicIP()
75+
} else if !IsIPv4(arg) && !IsIPv6(arg) {
76+
fmt.Println("Not a valid IP address.")
77+
return
7578
} else {
7679
myIP = arg
7780
}

0 commit comments

Comments
 (0)