DNS stands for Domain Name System, which relates to the way an IP address is translated into a name, such as packt.com, and vice versa. The logic behind the DNS.go utility, which will be developed in this section, is pretty simple: if the given command-line argument is a valid IP address, the program will process it as an IP address; otherwise, it will assume that it is dealing with a hostname that needs to be translated into one or more IP addresses.
The code for the DNS.go utility will be presented in three parts. The first part of the program contains the following Go code:
package main import ( "fmt" "net" "os" ) func lookIP(address string) ([]string, error) { hosts, err := net.LookupAddr(address) if err != nil { return nil, err } return hosts, nil } func lookHostname...