In this gist, We will check how we can extract SPF records in Go.


Go version

$ go version
go version go1.13 linux/amd64


DNS Library(

Install dependency

$ go get 


Here you can change nameserver according to your requirement. I have specified here google’s name server ( You can also use cloudflare’s nameserver (


You can make any DNS query with miekg/dns library. In the above script, we have looked up TXT Records and then we have searched for a string containing v=spf1.