import ( "net" "github.com/miekg/dns" ) func main() { // create a new DNS message msg := new(dns.Msg) msg.SetQuestion("example.com.", dns.TypeA) // send the message to a DNS resolver and get the response conn, err := net.Dial("udp", "8.8.8.8:53") if err != nil { // handle error } defer conn.Close() err = dns.Exchange(msg, conn) if err != nil { // handle error } // process the response // ... }
import ( "net" "github.com/miekg/dns" ) func main() { // create a new DNS message msg := new(dns.Msg) // add multiple questions to the message msg.SetQuestion("example.com.", dns.TypeA) msg.SetQuestion("mail.example.com.", dns.TypeMX) // send the message to a DNS resolver and get the response conn, err := net.Dial("udp", "8.8.8.8:53") if err != nil { // handle error } defer conn.Close() err = dns.Exchange(msg, conn) if err != nil { // handle error } // process the response // ... }In this example, we create a new DNS message and set multiple questions for the domains `example.com` and `mail.example.com` of types `A` and `MX`, respectively. We then send this message to a DNS resolver and get the response. The response can then be processed as needed. Determining the package library: `github.com/miekg/dns`.