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
Golang program for implementation of Quick Sort
Cannot use <variable> as <type> value in return statement error in Golang
Program in Go language to print Floyd's Triangle
Program in Go language to Find Largest Element of an Array
Undefined <variable/function> error in Golang
3 Different Examples - How State Works in React?