Small code clarifications after #2 and #3

This commit is contained in:
Aliaksandr Valialkin
2016-06-27 16:05:21 +03:00
parent c57419c995
commit c0dbba6832
+10 -3
View File
@@ -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