September 2017
Intermediate to advanced
466 pages
9h 33m
English
The name of this DNS utility will be lookHost.go and will be presented in three parts. The first part of the lookHost.go utility is the following:
package main import ( "fmt" "net" "os" )
The second part of the program has the following Go code:
func main() {
arguments := os.Args
if len(arguments) == 1 {
fmt.Println("Please provide an argument!")
os.Exit(100)
}
hostname := arguments[1]
IPs, err := net.LookupHost(hostname)
Similarly, the net.LookupHost() function also returns a string slice with the desired information.
The third part of the program has the following code, which is for error checking and printing the output of net.LookupHost():
if err != nil { fmt.Println(err) os.Exit(100) } for _, IP := range ...Read now
Unlock full access