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 :

http://golang.org/pkg/net/#LookupMX

http://golang.org/pkg/net/#MX

Advertisement