// Truncate discards all but the first n unread bytes from the buffer.60 // It panics if n is negative or greater than the length of the buffer.61 func (b *Buffer) Truncate(n int) b.lastRead = opInvalid63 switch case n b.Len():65 panic("bytes.Buffer: truncation out of range")66 case n == Reuse buffer space.688 b.off = b.buf = b.buf[0 : b.off n]71 }72 73 /Reset resets the buffer so it has no content.74 // b.Reset() is the same as b.Truncate(0).75 func (b *Buffer) Reset() { b.Truncate(0) code] * V6 R+ r. S& j
解决方案: : r3 A$ i; y# P8 _; h$ y
这一切都取决于你对清晰的定义。当然,其中一个有效的是:[code]slice = slice[:0]. C6 J f1 m' a( Y$ m) q