Golang ProgramsGolang Programs

Go program to find TXT records of a domain

This text record stores information about the SPF that can identify the authorized server to send email on behalf of your organization. The net.LookupTXT() function takes a domain name(facebook.com) as a string and returns a list of DNS TXT records as a slice of strings.
package main
 
import (
	"fmt"
	"net"
)
 
func main() {
	txtrecords, _ := net.LookupTXT("facebook.com")
 
	for _, txt := range txtrecords {
		fmt.Println(txt)
	}
}

The single TXT record for gmail.com is shown below.

C:\golang\dns>go run example7.go
v=spf1 redirect=_spf.facebook.com