Golang net.LookupMX() function example
package net
Golang net.LookupMX() function usage example
package main
import (
"fmt"
"net"
)
func main() {
mxRecord, err := net.LookupMX("socketloop.com")
if err != nil {
panic(err)
}
for i := 0; i < len(mxRecord); i++ {
fmt.Printf("Host : %s Priority : %d \n", mxRecord[i].Host, mxRecord[i].Pref)
}
}
Sample output :
Host : mx.zohomail.com. Priority : 10
Host : mx2.zohomail.com. Priority : 20
References :
Advertisement
Something interesting
Tutorials
+7.4k Golang : Convert source code to assembly language
+16.4k Golang : How to implement two-factor authentication?
+10.6k Golang : Simple File Server
+9.7k Golang : Format strings to SEO friendly URL example
+19.2k Golang : Check whether a network interface is up on your machine
+6.5k Golang : Convert an executable file into []byte example
+7.2k Golang : Check if one string(rune) is permutation of another string(rune)
+11.1k Golang : Web routing/multiplex example
+8.3k Swift : Convert (cast) Character to Integer?
+32.5k Golang : Copy directory - including sub-directories and files
+7.3k Golang : How to iterate a slice without using for loop?
+15.9k Golang : Read a file line by line