File tree Expand file tree Collapse file tree 1 file changed +3
-7
lines changed Expand file tree Collapse file tree 1 file changed +3
-7
lines changed Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ package utils
2
2
3
3
import "net"
4
4
5
- // IsIPv4 is plagiarism of net.ParseIP,
5
+ // IsIPv4 works the same way as net.ParseIP,
6
6
// but without check for IPv6 case and without returning net.IP slice, whereby IsIPv4 makes no allocations.
7
7
func IsIPv4 (s string ) bool {
8
8
for i := 0 ; i < net .IPv4len ; i ++ {
@@ -33,14 +33,10 @@ func IsIPv4(s string) bool {
33
33
s = s [ci :]
34
34
}
35
35
36
- if len (s ) != 0 {
37
- return false
38
- }
39
-
40
- return true
36
+ return len (s ) == 0
41
37
}
42
38
43
- // IsIPv6 is plagiarism of net.ParseIP,
39
+ // IsIPv6 works the same way as net.ParseIP,
44
40
// but without check for IPv4 case and without returning net.IP slice, whereby IsIPv6 makes no allocations.
45
41
func IsIPv6 (s string ) bool {
46
42
ellipsis := - 1 // position of ellipsis in ip
You can’t perform that action at this time.
0 commit comments