remove trivial IPv4 helper function (#4591)

This commit is contained in:
Marten Seemann
2024-07-21 15:50:03 -06:00
committed by GitHub
parent 5f8d146836
commit 29550811b4
4 changed files with 7 additions and 34 deletions

View File

@@ -1,10 +0,0 @@
package utils
import "net"
func IsIPv4(ip net.IP) bool {
// If ip is not an IPv4 address, To4 returns nil.
// Note that there might be some corner cases, where this is not correct.
// See https://stackoverflow.com/questions/22751035/golang-distinguish-ipv4-ipv6.
return ip.To4() != nil
}

View File

@@ -1,17 +0,0 @@
package utils
import (
"net"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)
var _ = Describe("IP", func() {
It("tells IPv4 and IPv6 addresses apart", func() {
Expect(IsIPv4(net.IPv4(127, 0, 0, 1))).To(BeTrue())
Expect(IsIPv4(net.IPv4zero)).To(BeTrue())
Expect(IsIPv4(net.IPv6zero)).To(BeFalse())
Expect(IsIPv4(net.IPv6loopback)).To(BeFalse())
})
})