I\'m developing a network application in Golang. I have a slice of IP addresses. Each time a request comes I use net.LookupIP(host)
to find out IP address of host w
You may use func (ip IP) Equal(x IP) bool
from net
package:
Equal reports whether ip and x are the same IP address. An IPv4 address and that same address in IPv6 form are considered to be equal.
Like this working sample:
package main
import (
"fmt"
"net"
)
func main() {
ip := net.ParseIP("127.0.0.1")
ips, err := net.LookupIP("localhost")
if err != nil {
panic(err)
}
for _, v := range ips {
if v.Equal(ip) {
fmt.Println(v)
}
}
}