func (dns *Msg) Truncate(size int) {
	if dns.IsTsig() != nil {
		return
	}
	if size < 512 {
		size = 512
	}
	l := msgLenWithCompressionMap(dns, nil)  
	if l <= size {
		dns.Compress = false
		return
	}
	dns.Compress = true
	edns0 := dns.popEdns0()
	if edns0 != nil {
		size -= Len(edns0)
	}
	compression := make(map[string]struct{})
	l = headerSize
	for _, r := range dns.Question {
		l += r.len(l, compression)
	}
	var numAnswer int
	if l < size {
		l, numAnswer = truncateLoop(dns.Answer, size, l, compression)
	}
	var numNS int
	if l < size {
		l, numNS = truncateLoop(dns.Ns, size, l, compression)
	}
	var numExtra int
	if l < size {
		_, numExtra = truncateLoop(dns.Extra, size, l, compression)
	}
	dns.Truncated = len(dns.Answer) > numAnswer ||
		len(dns.Ns) > numNS || len(dns.Extra) > numExtra
	dns.Answer = dns.Answer[:numAnswer]
	dns.Ns = dns.Ns[:numNS]
	dns.Extra = dns.Extra[:numExtra]
	if edns0 != nil {
		dns.Extra = append(dns.Extra, edns0)
	}
}
Truncate ensures the reply message will fit into the requested buffer
size by removing records that exceed the requested size.

It will first check if the reply fits without compression and then with
compression. If it won't fit with compression, Truncate then walks the
record adding as many records as possible without exceeding the
requested buffer size.

The TC bit will be set if any records were excluded from the message.
This indicates to that the client should retry over TCP.

According to RFC 2181, the TC bit should only be set if not all of the
"required" RRs can be included in the response. Unfortunately, we have
no way of knowing which RRs are required so we set the TC bit if any RR
had to be omitted from the response.

The appropriate buffer size can be retrieved from the requests OPT
record, if present, and is transport specific otherwise. dns.MinMsgSize
should be used for UDP requests without an OPT record, and
dns.MaxMsgSize for TCP requests without an OPT record.
package dns