bytes: Index | Examples | Files

package bytesp

import ""

Package bytesp is a plus to the standard "bytes" package.



Package Files

bytes.go slice.go


var ErrInvalidRune = errors.New("Slice: invalid rune")

error for a invalid rune

type Slice Uses

type Slice []byte

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



[65 98 99]

func NewPSlice Uses

func NewPSlice(bytes []byte) *Slice

NewPSlice returns a *Slice with intialized contents.

func (Slice) Close Uses

func (s Slice) Close() error

Close implements the io.Closer interface. It does nothing.

func (*Slice) Read Uses

func (s *Slice) Read(p []byte) (n int, err error)

Read implements the io.Reader interface. After some bytes are read, the slice shrinks.

func (*Slice) ReadByte Uses

func (s *Slice) ReadByte() (c byte, err error)

ReadByte implements the io.ByteReader interface.

func (*Slice) ReadFrom Uses

func (s *Slice) ReadFrom(r io.Reader) (n int64, err error)

ReadFrom implements the io.ReaderFrom interface.

func (*Slice) ReadRune Uses

func (s *Slice) ReadRune() (r rune, size int, err error)

ReadRune implements the io.RuneReader interface.

func (*Slice) Reset Uses

func (s *Slice) Reset()

Reset sets the length of the slice to 0.

func (*Slice) Skip Uses

func (s *Slice) Skip(n int64) (int64, error)

Skip skips n bytes.

func (*Slice) Write Uses

func (s *Slice) Write(p []byte) (n int, err error)

Write implements the io.Writer interface. Bytes are appended to the tail of the slice.

func (*Slice) WriteByte Uses

func (s *Slice) WriteByte(c byte) error

WriteByte implements the io.ByteWriter interface.

func (*Slice) WriteItoa Uses

func (s *Slice) WriteItoa(i int64, base int) (size int, err error)

WriteItoa converts i into text of the specified base and write to s.

func (*Slice) WriteRune Uses

func (s *Slice) WriteRune(r rune) (size int, err error)

WriteRune writes a single Unicode code point, returning the number of bytes written and any error.

func (*Slice) WriteString Uses

func (s *Slice) WriteString(str string) (size int, err 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.

func (Slice) WriteTo Uses

func (s Slice) WriteTo(w io.Writer) (n int64, err error)

WriteTo implements the io.WriterTo interface.

Package bytesp imports 4 packages (graph) and is imported by 22 packages. Updated 2016-07-14. Refresh now. Tools for package owners.