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 slice elements in Golang?
Naming Conventions for Golang Functions
Golang program for implementation of Median of Medians
GO Program to Find Factorial of a Number
Golang Web Server Example
Assign Default Value for Struct Field
How to remove multiple spaces in a string in GoLang?
How do you handle HTTP server health checks in Go?
This sample program demonstrates how to create multiple goroutines and how the goroutine scheduler behaves with three logical processors.
Syntax error: unexpected <token> error in Golang