msg := new(dns.Msg) msg.SetQuestion("example.com.", dns.TypeNS)
recvMsg, err := dns.ReadMsg(buf) if err != nil { log.Fatal("Failed to read message:", err) }
zone, _ := dns.NewZone("example.com. 3600 IN SOA ns.example.com. hostmaster.example.com. 2017010101 3600 7200 1209600 3600") nsRecord := zone.NewNS("example.com.", "ns1.example.com.") zone.Insert(nsRecord)Example Description: The above code examples demonstrate some of the functionalities provided by the github.com/miekg/dns package. The first code example creates a new DNS message with a single NS query for the domain example.com. The second example shows how to parse a received DNS message stored in a byte buffer. The third example illustrates how to manipulate NS records in a DNS zone, including creating a new NS record and inserting it into the zone. Package Library: github.com/miekg/dns