From c0dbba683231b1f07474c57ae73e379eebbb202c Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Mon, 27 Jun 2016 16:05:21 +0300 Subject: [PATCH] Small code clarifications after #2 and #3 --- bytebuffer.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/bytebuffer.go b/bytebuffer.go index aed9fb1..0e83cfe 100644 --- a/bytebuffer.go +++ b/bytebuffer.go @@ -14,8 +14,12 @@ type ByteBuffer struct { B []byte } -// Bytes returns all bytes contained in buffer -func (b *ByteBuffer) Bytes() []byte { return b.B } +// Bytes returns b.B, i.e. all the bytes accumulated in the buffer. +// +// The purpose of this function is bytes.Buffer compatibility. +func (b *ByteBuffer) Bytes() []byte { + return b.B +} // Write implements io.Writer - it appends p to ByteBuffer.B func (b *ByteBuffer) Write(p []byte) (int, error) { @@ -24,7 +28,10 @@ func (b *ByteBuffer) Write(p []byte) (int, error) { } // WriteByte appends the byte c to the buffer. -// The returned error is always nil. +// +// The purpose of this function is bytes.Buffer compatibility. +// +// The function always returns nil. func (b *ByteBuffer) WriteByte(c byte) error { b.B = append(b.B, c) return nil