In my small project of implementing a minimal DNS lookup utility in Go, I was trying to come up with a simplified logic of parsing the query response into a DNSPacket struct, which had the following structure:
type DNSPacket struct { Header *DNSHeader Questions *[]DNSQuestion Answers *[]DNSRecord Authorities *[]DNSRecord Additionals *[]DNSRecord } // initialize from Reader func (dr *DNSQuestion) FromBytes(reader *bytes.Reader) error { //... } func (dr *DNSRecord) FromBytes(reader *bytes.Reader) error { //.