This program will take an IP address and figure out what the hostnames are. The net.parseIP() function is used to validate the IP address provided, and net.LookupAddr() does the real work of figuring out what the hostname is.
By default, the pure Go resolver is used. The resolver can be overridden by setting the netdns value of the GODEBUG environment variable. Set the value of GODEBUG to go or cgo. You can do this in Linux with the following shell commands:
export GODEBUG=netdns=go # force pure Go resolver (Default)export GODEBUG=netdns=cgo # force cgo resolver
Here is the code for the program:
package mainimport ( "fmt" "log" "net" "os")
func main() { if len(os.Args) != 2 { log.Fatal("No IP address ...