import ( "github.com/miekg/dns" ) msg := new(dns.Msg) msg.SetQuestion("example.com", dns.TypeA)
buf := []byte{0x00, 0x01, 0x81, 0x80, 0x00, 0x01, 0x00, 0x02, 0x00, 0x02, 0x00, 0x00, 0x06, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x03, 0x63, 0x6f, 0x6d, 0x00, 0x00, 0x01, 0x00, 0x01, 0xc0, 0x0c, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x04, 0xac, 0xd9, 0x1c, 0x6e} msg := new(dns.Msg) msg.Unpack(buf)In this example, we have an incoming DNS response message in the `buf` variable. We have created a new `Msg` struct using the `new()` function. Then, we have used the `Unpack()` function to parse the incoming message and populate the fields of the `Msg` struct. In summary, the `Msg` struct in the `github.com/miekg/dns` package represents a DNS message, and it can be used to create new DNS requests or parse incoming DNS responses.