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
Print inverted full pyramid using star
Polymorphism in Go Programming Language
GO language program with example of Array Reverse Sort Functions for integer and strings
Empowering Developers: Google Cloud’s Generative AI Systems
Is There Still a Need for Programming in This AI World?
GO Program to take user input and addition of two strings