tailBytes returns the current tail contents in order. The caller must hold b.mu.
()
| 144 | // tailBytes returns the current tail contents in order. The |
| 145 | // caller must hold b.mu. |
| 146 | func (b *HeadTailBuffer) tailBytes() []byte { |
| 147 | if b.tail == nil { |
| 148 | return nil |
| 149 | } |
| 150 | if !b.tailFull { |
| 151 | // Haven't wrapped yet; data is [0, tailPos). |
| 152 | return b.tail[:b.tailPos] |
| 153 | } |
| 154 | // Wrapped: data is [tailPos, maxTail) + [0, tailPos). |
| 155 | out := make([]byte, b.maxTail) |
| 156 | n := copy(out, b.tail[b.tailPos:]) |
| 157 | copy(out[n:], b.tail[:b.tailPos]) |
| 158 | return out |
| 159 | } |
| 160 | |
| 161 | // Bytes returns a copy of the raw buffer contents. If no |
| 162 | // truncation has occurred the full output is returned; |