Here, We will learn how to do reverse lookup of network address in go. We can do it by using LookupAddr() function in net package in go golang. We can also say how to get domain name from IP address.
Function prototype:
func LookupAddr(addr string) (names []string, err error)
Return value:
LookupAddr() function in net package returns
performs a reverse lookup for net address. It
returns a list of names mapping to that address.
Example with code:
package main
import (
"fmt"
"net"
)
func main() {
nets, err := net.LookupAddr("www.google.com")
fmt.Println(nets, err)
nets, err = net.LookupAddr("www.techieindoor.com")
fmt.Println(nets, err)
nets, err = net.LookupAddr("8.8.4.4")
fmt.Println(nets, err)
}
Output:
[] Protocol not available
[] Protocol not available
[] Protocol not available
To learn more about golang, Please refer given below link:
https://www.techieindoor.com/go-lang-tutorial/
References:
https://golang.org/doc/
https://golang.org/pkg/