Go program to find MX records record of a domain
These records identify the servers that can exchange emails. The net.LookupMX() function takes a domain name as a string and returns a slice of MX structs sorted by preference. An MX struct is made up of a Host as a string and Pref as a uint16.
Example
package main
import (
"fmt"
"net"
)
func main() {
mxrecords, _ := net.LookupMX("facebook.com")
for _, mx := range mxrecords {
fmt.Println(mx.Host, mx.Pref)
}
}
The output list MX record for the domain(facebook.com) followed by preference.
msgin.vvv.facebook.com. 10
Most Helpful This Week
How to create Slice using new keyword in Golang?
GO Program to Generate Fibonacci Sequence Up to a Certain Number
Golang program for implementation of Huffman Coding Algorithm
React JS Count number of checkboxes are checked
Go program to find Name Server (NS) record of a domain
How to Convert string to integer type in Go?