Package bytesp is a plus to the standard "bytes" package.
error for a invalid rune
Slice is a wrapper type for byte. Its pointer form, *Slice, implements io.Reader, io.Writer, io.ByteReader, io.ByteWriter, io.Closer, io.ReaderFrom, io.WriterTo and io.RuneReader interfaces.
Benchmark shows *Slice is a better alternative for bytes.Buffer for writings and consumes less resource.
var b Slice b.WriteByte(65) b.WriteString("bc") fmt.Println(b) fmt.Println(string(b))
[65 98 99] Abc
NewPSlice returns a *Slice with intialized contents.
Close implements the io.Closer interface. It does nothing.
Read implements the io.Reader interface. After some bytes are read, the slice shrinks.
ReadByte implements the io.ByteReader interface.
ReadFrom implements the io.ReaderFrom interface.
ReadRune implements the io.RuneReader interface.
Reset sets the length of the slice to 0.
Skip skips n bytes.
Write implements the io.Writer interface. Bytes are appended to the tail of the slice.
WriteByte implements the io.ByteWriter interface.
WriteItoa converts i into text of the specified base and write to s.
WriteRune writes a single Unicode code point, returning the number of bytes written and any error.
WriteString appends the contents of str to the slice, growing the slice as needed. The return value n is the length of str; err is always nil.
WriteTo implements the io.WriterTo interface.