std/bytes
import "github.com/eugenioenko/goalchemy/std/bytes"Package bytes manipulates byte slices. Functions that return parts of their input return subslices that share its storage, as in Go.
var ErrTooLarge = errors.New("bytes.Buffer: too large")ErrTooLarge is returned when a Buffer cannot grow.
func Clone(b []byte) []byteClone returns a copy of b, or nil if b is nil.
Compare
Section titled “Compare”func Compare(a, b []byte) intCompare returns 0 if a == b, -1 if a < b, and +1 if a > b.
Contains
Section titled “Contains”func Contains(b, sub []byte) boolContains reports whether sub is within b.
ContainsRune
Section titled “ContainsRune”func ContainsRune(b []byte, r rune) boolContainsRune reports whether r is within b.
func Count(s, sep []byte) intCount counts the non-overlapping instances of sep in s.
func Equal(a, b []byte) boolEqual reports whether a and b have the same bytes; nil equals empty.
EqualFold
Section titled “EqualFold”func EqualFold(s, t []byte) boolEqualFold reports whether s and t are equal under simple Unicode case folding.
Fields
Section titled “Fields”func Fields(s []byte) [][]byteFields splits s around runs of white space into subslices of s.
HasPrefix
Section titled “HasPrefix”func HasPrefix(s, prefix []byte) boolHasPrefix reports whether s begins with prefix.
HasSuffix
Section titled “HasSuffix”func HasSuffix(s, suffix []byte) boolHasSuffix reports whether s ends with suffix.
func Index(s, sep []byte) intIndex returns the index of the first instance of sep in s, or -1.
IndexByte
Section titled “IndexByte”func IndexByte(b []byte, c byte) intIndexByte returns the index of the first instance of c in b, or -1.
IndexRune
Section titled “IndexRune”func IndexRune(s []byte, r rune) intIndexRune returns the index of the first instance of r in s, or -1.
func Join(s [][]byte, sep []byte) []byteJoin concatenates s with sep between elements into a new slice.
LastIndex
Section titled “LastIndex”func LastIndex(s, sep []byte) intLastIndex returns the index of the last instance of sep in s, or -1.
Repeat
Section titled “Repeat”func Repeat(b []byte, count int) []byteRepeat returns count copies of b. It panics if count is negative.
func Split(s, sep []byte) [][]byteSplit slices s into all subslices separated by sep.
SplitN
Section titled “SplitN”func SplitN(s, sep []byte, n int) [][]byteSplitN slices s into at most n subslices separated by sep; n < 0 means all.
ToLower
Section titled “ToLower”func ToLower(s []byte) []byteToLower returns a copy of s with every rune mapped to lower case.
ToUpper
Section titled “ToUpper”func ToUpper(s []byte) []byteToUpper returns a copy of s with every rune mapped to upper case.
TrimPrefix
Section titled “TrimPrefix”func TrimPrefix(s, prefix []byte) []byteTrimPrefix returns s without prefix if present.
TrimSpace
Section titled “TrimSpace”func TrimSpace(s []byte) []byteTrimSpace returns the subslice of s without leading and trailing white space.
TrimSuffix
Section titled “TrimSuffix”func TrimSuffix(s, suffix []byte) []byteTrimSuffix returns s without suffix if present.
type Buffer
Section titled “type Buffer”type Buffer struct {}Buffer is a growable byte buffer. The zero value is an empty buffer.
NewBuffer
Section titled “NewBuffer”func NewBuffer(buf []byte) *BufferNewBuffer returns a Buffer whose initial contents are buf.
NewBufferString
Section titled “NewBufferString”func NewBufferString(s string) *BufferNewBufferString returns a Buffer whose initial contents are s.
Buffer.Bytes
Section titled “Buffer.Bytes”func (b *Buffer) Bytes() []byteBytes returns the unread portion of the buffer, sharing its storage.
Buffer.Grow
Section titled “Buffer.Grow”func (b *Buffer) Grow(n int)Grow ensures space for another n bytes. It panics if n is negative.
Buffer.Len
Section titled “Buffer.Len”func (b *Buffer) Len() intLen returns the number of unread bytes.
Buffer.Next
Section titled “Buffer.Next”func (b *Buffer) Next(n int) []byteNext returns the next n unread bytes, or all of them if fewer remain, and advances past them.
Buffer.Read
Section titled “Buffer.Read”func (b *Buffer) Read(p []byte) (int, error)Read reads the next len(p) bytes from the buffer, or until it is drained. It returns io.EOF when the buffer has no data and p is not empty.
Buffer.ReadByte
Section titled “Buffer.ReadByte”func (b *Buffer) ReadByte() (byte, error)ReadByte returns the next byte, or io.EOF when the buffer is empty.
Buffer.ReadFrom
Section titled “Buffer.ReadFrom”func (b *Buffer) ReadFrom(r io.Reader) (int64, error)ReadFrom appends data from r until io.EOF and returns the number of bytes read. Errors other than io.EOF are returned.
Buffer.Reset
Section titled “Buffer.Reset”func (b *Buffer) Reset()Reset empties the buffer.
Buffer.String
Section titled “Buffer.String”func (b *Buffer) String() stringString returns the unread portion of the buffer as a string.
Buffer.Truncate
Section titled “Buffer.Truncate”func (b *Buffer) Truncate(n int)Truncate keeps the first n unread bytes. It panics if n is out of range.
Buffer.Write
Section titled “Buffer.Write”func (b *Buffer) Write(p []byte) (int, error)Write appends p and always returns len(p), nil.
Buffer.WriteByte
Section titled “Buffer.WriteByte”func (b *Buffer) WriteByte(c byte) errorWriteByte appends c and always returns nil.
Buffer.WriteRune
Section titled “Buffer.WriteRune”func (b *Buffer) WriteRune(r rune) (int, error)WriteRune appends the UTF-8 encoding of r and returns its length.
Buffer.WriteString
Section titled “Buffer.WriteString”func (b *Buffer) WriteString(s string) (int, error)WriteString appends s and always returns len(s), nil.
Buffer.WriteTo
Section titled “Buffer.WriteTo”func (b *Buffer) WriteTo(w io.Writer) (int64, error)WriteTo writes the unread data to w until the buffer is drained or an error occurs.
type Reader
Section titled “type Reader”type Reader struct {}Reader implements io.Reader, io.ReaderAt, io.Seeker, io.WriterTo, io.ByteScanner and io.RuneScanner over a byte slice. It does not modify the slice. The zero value reads nothing.
NewReader
Section titled “NewReader”func NewReader(b []byte) *ReaderNewReader returns a Reader reading from b.
Reader.Len
Section titled “Reader.Len”func (r *Reader) Len() intLen returns the number of unread bytes.
Reader.Read
Section titled “Reader.Read”func (r *Reader) Read(b []byte) (n int, err error)Read implements io.Reader.
Reader.ReadAt
Section titled “Reader.ReadAt”func (r *Reader) ReadAt(b []byte, off int64) (n int, err error)ReadAt implements io.ReaderAt. It does not change the read position.
Reader.ReadByte
Section titled “Reader.ReadByte”func (r *Reader) ReadByte() (byte, error)ReadByte implements io.ByteReader.
Reader.ReadRune
Section titled “Reader.ReadRune”func (r *Reader) ReadRune() (ch rune, size int, err error)ReadRune implements io.RuneReader.
Reader.Reset
Section titled “Reader.Reset”func (r *Reader) Reset(b []byte)Reset resets the Reader to read from b.
Reader.Seek
Section titled “Reader.Seek”func (r *Reader) Seek(offset int64, whence int) (int64, error)Seek implements io.Seeker. Seeking past the end is allowed.
Reader.Size
Section titled “Reader.Size”func (r *Reader) Size() int64Size returns the original length of the underlying slice.
Reader.UnreadByte
Section titled “Reader.UnreadByte”func (r *Reader) UnreadByte() errorUnreadByte steps back one byte.
Reader.UnreadRune
Section titled “Reader.UnreadRune”func (r *Reader) UnreadRune() errorUnreadRune steps back over the rune returned by the previous ReadRune.
Reader.WriteTo
Section titled “Reader.WriteTo”func (r *Reader) WriteTo(w io.Writer) (n int64, err error)WriteTo implements io.WriterTo, writing the unread data to w.