package bytes

Import Path
	bytes (on golang.org and go.dev)

Dependency Relation
	imports 5 packages, and imported by 54 packages

Involved Source Files
	    buffer.go
	d-> bytes.go
	    reader.go

Exported Type Names

type Buffer (struct) A Buffer is a variable-sized buffer of bytes with Read and Write methods. The zero value for Buffer is an empty buffer ready to use. (*T) Bytes() []byte (*T) Cap() int (*T) Grow(n int) (*T) Len() int (*T) Next(n int) []byte (*T) Read(p []byte) (n int, err error) (*T) ReadByte() (byte, error) (*T) ReadBytes(delim byte) (line []byte, err error) (*T) ReadFrom(r io.Reader) (n int64, err error) (*T) ReadRune() (r rune, size int, err error) (*T) ReadString(delim byte) (line string, err error) (*T) Reset() (*T) String() string (*T) Truncate(n int) (*T) UnreadByte() error (*T) UnreadRune() error (*T) Write(p []byte) (n int, err error) (*T) WriteByte(c byte) error (*T) WriteRune(r rune) (n int, err error) (*T) WriteString(s string) (n int, err error) (*T) WriteTo(w io.Writer) (n int64, err error) *T : compress/flate.Reader *T : expvar.Var *T : fmt.Stringer *T : image/jpeg.Reader *T : io.ByteReader *T : io.ByteScanner *T : io.ByteWriter *T : io.Reader *T : io.ReaderFrom *T : io.ReadWriter *T : io.RuneReader *T : io.RuneScanner *T : io.StringWriter *T : io.Writer *T : io.WriterTo func NewBuffer(buf []byte) *Buffer func NewBufferString(s string) *Buffer func encoding/json.Compact(dst *Buffer, src []byte) error func encoding/json.HTMLEscape(dst *Buffer, src []byte) func encoding/json.Indent(dst *Buffer, src []byte, prefix, indent string) error func go/types.WriteExpr(buf *Buffer, x ast.Expr) func go/types.WriteSignature(buf *Buffer, sig *types.Signature, qf types.Qualifier) func go/types.WriteType(buf *Buffer, typ types.Type, qf types.Qualifier)
type Reader (struct) A Reader implements the io.Reader, io.ReaderAt, io.WriterTo, io.Seeker, io.ByteScanner, and io.RuneScanner interfaces by reading from a byte slice. Unlike a Buffer, a Reader is read-only and supports seeking. The zero value for Reader operates like a Reader of an empty slice. (*T) Len() int (*T) Read(b []byte) (n int, err error) (*T) ReadAt(b []byte, off int64) (n int, err error) (*T) ReadByte() (byte, error) (*T) ReadRune() (ch rune, size int, err error) (*T) Reset(b []byte) (*T) Seek(offset int64, whence int) (int64, error) (*T) Size() int64 (*T) UnreadByte() error (*T) UnreadRune() error (*T) WriteTo(w io.Writer) (n int64, err error) *T : compress/flate.Reader *T : image/jpeg.Reader *T : io.ByteReader *T : io.ByteScanner *T : io.Reader *T : io.ReaderAt *T : io.ReadSeeker *T : io.RuneReader *T : io.RuneScanner *T : io.Seeker *T : io.WriterTo func NewReader(b []byte) *Reader
Exported Values
func Compare(a, b []byte) int Compare returns an integer comparing two byte slices lexicographically. The result will be 0 if a==b, -1 if a < b, and +1 if a > b. A nil argument is equivalent to an empty slice.
func Contains(b, subslice []byte) bool Contains reports whether subslice is within b.
func ContainsAny(b []byte, chars string) bool ContainsAny reports whether any of the UTF-8-encoded code points in chars are within b.
func ContainsRune(b []byte, r rune) bool ContainsRune reports whether the rune is contained in the UTF-8-encoded byte slice b.
func Count(s, sep []byte) int Count counts the number of non-overlapping instances of sep in s. If sep is an empty slice, Count returns 1 + the number of UTF-8-encoded code points in s.
func Equal(a, b []byte) bool Equal reports whether a and b are the same length and contain the same bytes. A nil argument is equivalent to an empty slice.
func EqualFold(s, t []byte) bool EqualFold reports whether s and t, interpreted as UTF-8 strings, are equal under Unicode case-folding, which is a more general form of case-insensitivity.
var ErrTooLarge error ErrTooLarge is passed to panic if memory cannot be allocated to store data in a buffer.
func Fields(s []byte) [][]byte Fields interprets s as a sequence of UTF-8-encoded code points. It splits the slice s around each instance of one or more consecutive white space characters, as defined by unicode.IsSpace, returning a slice of subslices of s or an empty slice if s contains only white space.
func FieldsFunc(s []byte, f func(rune) bool) [][]byte FieldsFunc interprets s as a sequence of UTF-8-encoded code points. It splits the slice s at each run of code points c satisfying f(c) and returns a slice of subslices of s. If all code points in s satisfy f(c), or len(s) == 0, an empty slice is returned. FieldsFunc makes no guarantees about the order in which it calls f(c) and assumes that f always returns the same value for a given c.
func HasPrefix(s, prefix []byte) bool HasPrefix tests whether the byte slice s begins with prefix.
func HasSuffix(s, suffix []byte) bool HasSuffix tests whether the byte slice s ends with suffix.
func Index(s, sep []byte) int Index returns the index of the first instance of sep in s, or -1 if sep is not present in s.
func IndexAny(s []byte, chars string) int IndexAny interprets s as a sequence of UTF-8-encoded Unicode code points. It returns the byte index of the first occurrence in s of any of the Unicode code points in chars. It returns -1 if chars is empty or if there is no code point in common.
func IndexByte(b []byte, c byte) int IndexByte returns the index of the first instance of c in b, or -1 if c is not present in b.
func IndexFunc(s []byte, f func(r rune) bool) int IndexFunc interprets s as a sequence of UTF-8-encoded code points. It returns the byte index in s of the first Unicode code point satisfying f(c), or -1 if none do.
func IndexRune(s []byte, r rune) int IndexRune interprets s as a sequence of UTF-8-encoded code points. It returns the byte index of the first occurrence in s of the given rune. It returns -1 if rune is not present in s. If r is utf8.RuneError, it returns the first instance of any invalid UTF-8 byte sequence.
func Join(s [][]byte, sep []byte) []byte Join concatenates the elements of s to create a new byte slice. The separator sep is placed between elements in the resulting slice.
func LastIndex(s, sep []byte) int LastIndex returns the index of the last instance of sep in s, or -1 if sep is not present in s.
func LastIndexAny(s []byte, chars string) int LastIndexAny interprets s as a sequence of UTF-8-encoded Unicode code points. It returns the byte index of the last occurrence in s of any of the Unicode code points in chars. It returns -1 if chars is empty or if there is no code point in common.
func LastIndexByte(s []byte, c byte) int LastIndexByte returns the index of the last instance of c in s, or -1 if c is not present in s.
func LastIndexFunc(s []byte, f func(r rune) bool) int LastIndexFunc interprets s as a sequence of UTF-8-encoded code points. It returns the byte index in s of the last Unicode code point satisfying f(c), or -1 if none do.
func Map(mapping func(r rune) rune, s []byte) []byte Map returns a copy of the byte slice s with all its characters modified according to the mapping function. If mapping returns a negative value, the character is dropped from the byte slice with no replacement. The characters in s and the output are interpreted as UTF-8-encoded code points.
const MinRead = 512 MinRead is the minimum slice size passed to a Read call by Buffer.ReadFrom. As long as the Buffer has at least MinRead bytes beyond what is required to hold the contents of r, ReadFrom will not grow the underlying buffer.
func NewBuffer(buf []byte) *Buffer NewBuffer creates and initializes a new Buffer using buf as its initial contents. The new Buffer takes ownership of buf, and the caller should not use buf after this call. NewBuffer is intended to prepare a Buffer to read existing data. It can also be used to set the initial size of the internal buffer for writing. To do that, buf should have the desired capacity but a length of zero. In most cases, new(Buffer) (or just declaring a Buffer variable) is sufficient to initialize a Buffer.
func NewBufferString(s string) *Buffer NewBufferString creates and initializes a new Buffer using string s as its initial contents. It is intended to prepare a buffer to read an existing string. In most cases, new(Buffer) (or just declaring a Buffer variable) is sufficient to initialize a Buffer.
func NewReader(b []byte) *Reader NewReader returns a new Reader reading from b.
func Repeat(b []byte, count int) []byte Repeat returns a new byte slice consisting of count copies of b. It panics if count is negative or if the result of (len(b) * count) overflows.
func Replace(s, old, new []byte, n int) []byte Replace returns a copy of the slice s with the first n non-overlapping instances of old replaced by new. If old is empty, it matches at the beginning of the slice and after each UTF-8 sequence, yielding up to k+1 replacements for a k-rune slice. If n < 0, there is no limit on the number of replacements.
func ReplaceAll(s, old, new []byte) []byte ReplaceAll returns a copy of the slice s with all non-overlapping instances of old replaced by new. If old is empty, it matches at the beginning of the slice and after each UTF-8 sequence, yielding up to k+1 replacements for a k-rune slice.
func Runes(s []byte) []rune Runes interprets s as a sequence of UTF-8-encoded code points. It returns a slice of runes (Unicode code points) equivalent to s.
func Split(s, sep []byte) [][]byte Split slices s into all subslices separated by sep and returns a slice of the subslices between those separators. If sep is empty, Split splits after each UTF-8 sequence. It is equivalent to SplitN with a count of -1.
func SplitAfter(s, sep []byte) [][]byte SplitAfter slices s into all subslices after each instance of sep and returns a slice of those subslices. If sep is empty, SplitAfter splits after each UTF-8 sequence. It is equivalent to SplitAfterN with a count of -1.
func SplitAfterN(s, sep []byte, n int) [][]byte SplitAfterN slices s into subslices after each instance of sep and returns a slice of those subslices. If sep is empty, SplitAfterN splits after each UTF-8 sequence. The count determines the number of subslices to return: n > 0: at most n subslices; the last subslice will be the unsplit remainder. n == 0: the result is nil (zero subslices) n < 0: all subslices
func SplitN(s, sep []byte, n int) [][]byte SplitN slices s into subslices separated by sep and returns a slice of the subslices between those separators. If sep is empty, SplitN splits after each UTF-8 sequence. The count determines the number of subslices to return: n > 0: at most n subslices; the last subslice will be the unsplit remainder. n == 0: the result is nil (zero subslices) n < 0: all subslices
func Title(s []byte) []byte Title treats s as UTF-8-encoded bytes and returns a copy with all Unicode letters that begin words mapped to their title case. BUG(rsc): The rule Title uses for word boundaries does not handle Unicode punctuation properly.
func ToLower(s []byte) []byte ToLower returns a copy of the byte slice s with all Unicode letters mapped to their lower case.
func ToLowerSpecial(c unicode.SpecialCase, s []byte) []byte ToLowerSpecial treats s as UTF-8-encoded bytes and returns a copy with all the Unicode letters mapped to their lower case, giving priority to the special casing rules.
func ToTitle(s []byte) []byte ToTitle treats s as UTF-8-encoded bytes and returns a copy with all the Unicode letters mapped to their title case.
func ToTitleSpecial(c unicode.SpecialCase, s []byte) []byte ToTitleSpecial treats s as UTF-8-encoded bytes and returns a copy with all the Unicode letters mapped to their title case, giving priority to the special casing rules.
func ToUpper(s []byte) []byte ToUpper returns a copy of the byte slice s with all Unicode letters mapped to their upper case.
func ToUpperSpecial(c unicode.SpecialCase, s []byte) []byte ToUpperSpecial treats s as UTF-8-encoded bytes and returns a copy with all the Unicode letters mapped to their upper case, giving priority to the special casing rules.
func ToValidUTF8(s, replacement []byte) []byte ToValidUTF8 treats s as UTF-8-encoded bytes and returns a copy with each run of bytes representing invalid UTF-8 replaced with the bytes in replacement, which may be empty.
func Trim(s []byte, cutset string) []byte Trim returns a subslice of s by slicing off all leading and trailing UTF-8-encoded code points contained in cutset.
func TrimFunc(s []byte, f func(r rune) bool) []byte TrimFunc returns a subslice of s by slicing off all leading and trailing UTF-8-encoded code points c that satisfy f(c).
func TrimLeft(s []byte, cutset string) []byte TrimLeft returns a subslice of s by slicing off all leading UTF-8-encoded code points contained in cutset.
func TrimLeftFunc(s []byte, f func(r rune) bool) []byte TrimLeftFunc treats s as UTF-8-encoded bytes and returns a subslice of s by slicing off all leading UTF-8-encoded code points c that satisfy f(c).
func TrimPrefix(s, prefix []byte) []byte TrimPrefix returns s without the provided leading prefix string. If s doesn't start with prefix, s is returned unchanged.
func TrimRight(s []byte, cutset string) []byte TrimRight returns a subslice of s by slicing off all trailing UTF-8-encoded code points that are contained in cutset.
func TrimRightFunc(s []byte, f func(r rune) bool) []byte TrimRightFunc returns a subslice of s by slicing off all trailing UTF-8-encoded code points c that satisfy f(c).
func TrimSpace(s []byte) []byte TrimSpace returns a subslice of s by slicing off all leading and trailing white space, as defined by Unicode.
func TrimSuffix(s, suffix []byte) []byte TrimSuffix returns s without the provided trailing suffix string. If s doesn't end with suffix, s is returned unchanged.