August 2019
Beginner to intermediate
798 pages
17h 2m
English
Another very popular DNS request has to do with getting the MX records of a domain. The MX records specify the mail servers of a domain. The code for the MXrecords.go utility will perform this task with Go. The first part of the MXrecords.go utility is shown in the following Go code:
package main
import (
"fmt"
"net"
"os"
)
func main() {
arguments := os.Args
if len(arguments) == 1 {
fmt.Println("Need a domain name!")
return
}
The second part of MXrecords.go contains the following Go code:
domain := arguments[1]
MXs, err := net.LookupMX(domain)
if err != nil {
fmt.Println(err)
return
}
for _, MX := range MXs {
fmt.Println(MX.Host)
}
}
The code for MXrecords.go works in a similar way to the code for ...
Read now
Unlock full access