MCPcopy
hub / github.com/pquerna/ffjson / Truncate

Method Truncate

fflib/v1/buffer.go:110–117  ·  view source on GitHub ↗

Truncate discards all but the first n unread bytes from the buffer. It panics if n is negative or greater than the length of the buffer.

(n int)

Source from the content-addressed store, hash-verified

108// Truncate discards all but the first n unread bytes from the buffer.
109// It panics if n is negative or greater than the length of the buffer.
110func (b *Buffer) Truncate(n int) {
111 if n == 0 {
112 b.off = 0
113 b.buf = b.buf[0:0]
114 } else {
115 b.buf = b.buf[0 : b.off+n]
116 }
117}
118
119// Reset resets the buffer so it has no content.
120// b.Reset() is the same as b.Truncate(0).

Callers 7

ResetMethod · 0.95
growMethod · 0.95
ReadFromMethod · 0.95
WriteToMethod · 0.95
ReadMethod · 0.95
ReadByteMethod · 0.95
ReadRuneMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected