Go program to find CNAME record of a domain


This is the abbreviation for canonical name. CNAMEs are essentially domain and subdomain text aliases to bind traffic. The net.LookupCNAME() function accepts a host-name(m.facebook.com) as a string and returns a single canonical domain name for the given host.

Example

package main
 
import (
	"fmt"
	"net"
)
 
func main() {
	cname, _ := net.LookupCNAME("m.facebook.com")
	fmt.Println(cname)
}

The CNAME record that was returned for the m.facebook.com domain is shown below:

star-mini.c10r.facebook.com.
Most Helpful This Week