refine buffer interface

This commit is contained in:
Darien Raymond
2018-07-30 22:45:06 +02:00
parent a4030dd237
commit 206f52affc
14 changed files with 42 additions and 58 deletions
+5 -5
View File
@@ -35,11 +35,6 @@ func (b *Buffer) Clear() {
b.end = 0
}
// AppendBytes appends one or more bytes to the end of the buffer.
func (b *Buffer) AppendBytes(bytes ...byte) (int, error) {
return b.Write(bytes)
}
// AppendSupplier appends the content of a BytesWriter to the buffer.
func (b *Buffer) AppendSupplier(writer Supplier) error {
nBytes, err := writer(b.v[b.end:])
@@ -145,6 +140,11 @@ func (b *Buffer) Write(data []byte) (int, error) {
return nBytes, nil
}
// WriteBytes appends one or more bytes to the end of the buffer.
func (b *Buffer) WriteBytes(bytes ...byte) (int, error) {
return b.Write(bytes)
}
// Read implements io.Reader.Read().
func (b *Buffer) Read(data []byte) (int, error) {
if b.Len() == 0 {