summaryrefslogtreecommitdiffstats
path: root/vendor/go.uber.org/zap/buffer/buffer.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/go.uber.org/zap/buffer/buffer.go')
-rw-r--r--vendor/go.uber.org/zap/buffer/buffer.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/vendor/go.uber.org/zap/buffer/buffer.go b/vendor/go.uber.org/zap/buffer/buffer.go
index d15f7fdb3..7592e8c63 100644
--- a/vendor/go.uber.org/zap/buffer/buffer.go
+++ b/vendor/go.uber.org/zap/buffer/buffer.go
@@ -98,6 +98,15 @@ func (b *Buffer) Write(bs []byte) (int, error) {
return len(bs), nil
}
+// TrimNewline trims any final "\n" byte from the end of the buffer.
+func (b *Buffer) TrimNewline() {
+ if i := len(b.bs) - 1; i >= 0 {
+ if b.bs[i] == '\n' {
+ b.bs = b.bs[:i]
+ }
+ }
+}
+
// Free returns the Buffer to its Pool.
//
// Callers must not retain references to the Buffer after calling Free.