Imports #
"errors"
"io"
"unicode/utf8"
"internal/bytealg"
"math/bits"
"unicode"
"unicode/utf8"
_ "unsafe"
"iter"
"unicode"
"unicode/utf8"
"errors"
"io"
"unicode/utf8"
"errors"
"io"
"unicode/utf8"
"internal/bytealg"
"math/bits"
"unicode"
"unicode/utf8"
_ "unsafe"
"iter"
"unicode"
"unicode/utf8"
"errors"
"io"
"unicode/utf8"
ErrTooLarge is passed to panic if memory cannot be allocated to store data in a buffer.
var ErrTooLarge = *ast.CallExprMinRead is the minimum slice size passed to a [Buffer.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, [Buffer.ReadFrom] will not grow the underlying buffer.
const MinRead = 512var asciiSpace = [256]uint8{...}var errNegativeRead = *ast.CallExprvar errUnreadByte = *ast.CallExprconst maxInt = *ast.CallExprDon't use iota for these, as the values need to correspond with the names and comments, which is easier to see when being explicit.
const opInvalid readOp = 0Don't use iota for these, as the values need to correspond with the names and comments, which is easier to see when being explicit.
const opRead readOp = *ast.UnaryExprDon't use iota for these, as the values need to correspond with the names and comments, which is easier to see when being explicit.
const opReadRune1 readOp = 1Don't use iota for these, as the values need to correspond with the names and comments, which is easier to see when being explicit.
const opReadRune2 readOp = 2Don't use iota for these, as the values need to correspond with the names and comments, which is easier to see when being explicit.
const opReadRune3 readOp = 3Don't use iota for these, as the values need to correspond with the names and comments, which is easier to see when being explicit.
const opReadRune4 readOp = 4smallBufferSize is an initial allocation minimal capacity.
const smallBufferSize = 64asciiSet is a 32-byte value, where each bit represents the presence of a given ASCII character in the set. The 128-bits of the lower 16 bytes, starting with the least-significant bit of the lowest word to the most-significant bit of the highest word, map to the full range of all 128 ASCII characters. The 128-bits of the upper 16 bytes will be zeroed, ensuring that any non-ASCII character will be reported as not in the set. This allocates a total of 32 bytes even though the upper half is unused to avoid bounds checks in asciiSet.contains.
type asciiSet [8]uint32The readOp constants describe the last action performed on the buffer, so that UnreadRune and UnreadByte can check for invalid usage. opReadRuneX constants are chosen such that converted to int they correspond to the rune size that was read.
type readOp int8A Buffer is a variable-sized buffer of bytes with [Buffer.Read] and [Buffer.Write] methods. The zero value for Buffer is an empty buffer ready to use.
type Buffer struct {
buf []byte
off int
lastRead readOp
}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.
type Reader struct {
s []byte
i int64
prevRune int
}Available returns how many bytes are unused in the buffer.
func (b *Buffer) Available() intAvailableBuffer returns an empty buffer with b.Available() capacity. This buffer is intended to be appended to and passed to an immediately succeeding [Buffer.Write] call. The buffer is only valid until the next write operation on b.
func (b *Buffer) AvailableBuffer() []byteBytes returns a slice of length b.Len() holding the unread portion of the buffer. The slice is valid for use only until the next buffer modification (that is, only until the next call to a method like [Buffer.Read], [Buffer.Write], [Buffer.Reset], or [Buffer.Truncate]). The slice aliases the buffer content at least until the next buffer modification, so immediate changes to the slice will affect the result of future reads.
func (b *Buffer) Bytes() []byteCap returns the capacity of the buffer's underlying byte slice, that is, the total space allocated for the buffer's data.
func (b *Buffer) Cap() intClone returns a copy of b[:len(b)]. The result may have additional unused capacity. Clone(nil) returns nil.
func Clone(b []byte) []byteCompare 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 Compare(a []byte, b []byte) intContains reports whether subslice is within b.
func Contains(b []byte, subslice []byte) boolContainsAny reports whether any of the UTF-8-encoded code points in chars are within b.
func ContainsAny(b []byte, chars string) boolContainsFunc reports whether any of the UTF-8-encoded code points r within b satisfy f(r).
func ContainsFunc(b []byte, f func(rune) bool) boolContainsRune reports whether the rune is contained in the UTF-8-encoded byte slice b.
func ContainsRune(b []byte, r rune) boolCount 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 Count(s []byte, sep []byte) intCut slices s around the first instance of sep, returning the text before and after sep. The found result reports whether sep appears in s. If sep does not appear in s, cut returns s, nil, false. Cut returns slices of the original slice s, not copies.
func Cut(s []byte, sep []byte) (before []byte, after []byte, found bool)CutPrefix returns s without the provided leading prefix byte slice and reports whether it found the prefix. If s doesn't start with prefix, CutPrefix returns s, false. If prefix is the empty byte slice, CutPrefix returns s, true. CutPrefix returns slices of the original slice s, not copies.
func CutPrefix(s []byte, prefix []byte) (after []byte, found bool)CutSuffix returns s without the provided ending suffix byte slice and reports whether it found the suffix. If s doesn't end with suffix, CutSuffix returns s, false. If suffix is the empty byte slice, CutSuffix returns s, true. CutSuffix returns slices of the original slice s, not copies.
func CutSuffix(s []byte, suffix []byte) (before []byte, found 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 Equal(a []byte, b []byte) boolEqualFold reports whether s and t, interpreted as UTF-8 strings, are equal under simple Unicode case-folding, which is a more general form of case-insensitivity.
func EqualFold(s []byte, t []byte) boolFields 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 Fields(s []byte) [][]byteFieldsFunc 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 FieldsFunc(s []byte, f func(rune) bool) [][]byteFieldsFuncSeq returns an iterator over subslices of s split around runs of Unicode code points satisfying f(c). The iterator yields the same subslices that would be returned by [FieldsFunc](s), but without constructing a new slice containing the subslices.
func FieldsFuncSeq(s []byte, f func(rune) bool) *ast.IndexExprFieldsSeq returns an iterator over subslices of s split around runs of whitespace characters, as defined by [unicode.IsSpace]. The iterator yields the same subslices that would be returned by [Fields](s), but without constructing a new slice containing the subslices.
func FieldsSeq(s []byte) *ast.IndexExprGrow grows the buffer's capacity, if necessary, to guarantee space for another n bytes. After Grow(n), at least n bytes can be written to the buffer without another allocation. If n is negative, Grow will panic. If the buffer can't grow it will panic with [ErrTooLarge].
func (b *Buffer) Grow(n int)HasPrefix reports whether the byte slice s begins with prefix.
func HasPrefix(s []byte, prefix []byte) boolHasSuffix reports whether the byte slice s ends with suffix.
func HasSuffix(s []byte, suffix []byte) boolIndex returns the index of the first instance of sep in s, or -1 if sep is not present in s.
func Index(s []byte, sep []byte) intIndexAny 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 IndexAny(s []byte, chars string) intIndexByte returns the index of the first instance of c in b, or -1 if c is not present in b.
func IndexByte(b []byte, c byte) intIndexFunc 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 IndexFunc(s []byte, f func(r rune) bool) intIndexRune 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 IndexRune(s []byte, r rune) intJoin concatenates the elements of s to create a new byte slice. The separator sep is placed between elements in the resulting slice.
func Join(s [][]byte, sep []byte) []byteLastIndex returns the index of the last instance of sep in s, or -1 if sep is not present in s.
func LastIndex(s []byte, sep []byte) intLastIndexAny 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 LastIndexAny(s []byte, chars string) intLastIndexByte returns the index of the last instance of c in s, or -1 if c is not present in s.
func LastIndexByte(s []byte, c byte) intLastIndexFunc 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 LastIndexFunc(s []byte, f func(r rune) bool) intLen returns the number of bytes of the unread portion of the slice.
func (r *Reader) Len() intLen returns the number of bytes of the unread portion of the buffer; b.Len() == len(b.Bytes()).
func (b *Buffer) Len() intLines returns an iterator over the newline-terminated lines in the byte slice s. The lines yielded by the iterator include their terminating newlines. If s is empty, the iterator yields no lines at all. If s does not end in a newline, the final yielded line will not end in a newline. It returns a single-use iterator.
func Lines(s []byte) *ast.IndexExprMap 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.
func Map(mapping func(r rune) rune, s []byte) []byteNewBuffer 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 NewBuffer(buf []byte) *BufferNewBufferString 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 NewBufferString(s string) *BufferNewReader returns a new [Reader] reading from b.
func NewReader(b []byte) *ReaderNext returns a slice containing the next n bytes from the buffer, advancing the buffer as if the bytes had been returned by [Buffer.Read]. If there are fewer than n bytes in the buffer, Next returns the entire buffer. The slice is only valid until the next call to a read or write method.
func (b *Buffer) Next(n int) []byteRead implements the [io.Reader] interface.
func (r *Reader) Read(b []byte) (n int, err error)Read reads the next len(p) bytes from the buffer or until the buffer is drained. The return value n is the number of bytes read. If the buffer has no data to return, err is [io.EOF] (unless len(p) is zero); otherwise it is nil.
func (b *Buffer) Read(p []byte) (n int, err error)ReadAt implements the [io.ReaderAt] interface.
func (r *Reader) ReadAt(b []byte, off int64) (n int, err error)ReadByte implements the [io.ByteReader] interface.
func (r *Reader) ReadByte() (byte, error)ReadByte reads and returns the next byte from the buffer. If no byte is available, it returns error [io.EOF].
func (b *Buffer) ReadByte() (byte, error)ReadBytes reads until the first occurrence of delim in the input, returning a slice containing the data up to and including the delimiter. If ReadBytes encounters an error before finding a delimiter, it returns the data read before the error and the error itself (often [io.EOF]). ReadBytes returns err != nil if and only if the returned data does not end in delim.
func (b *Buffer) ReadBytes(delim byte) (line []byte, err error)ReadFrom reads data from r until EOF and appends it to the buffer, growing the buffer as needed. The return value n is the number of bytes read. Any error except io.EOF encountered during the read is also returned. If the buffer becomes too large, ReadFrom will panic with [ErrTooLarge].
func (b *Buffer) ReadFrom(r io.Reader) (n int64, err error)ReadRune reads and returns the next UTF-8-encoded Unicode code point from the buffer. If no bytes are available, the error returned is io.EOF. If the bytes are an erroneous UTF-8 encoding, it consumes one byte and returns U+FFFD, 1.
func (b *Buffer) ReadRune() (r rune, size int, err error)ReadRune implements the [io.RuneReader] interface.
func (r *Reader) ReadRune() (ch rune, size int, err error)ReadString reads until the first occurrence of delim in the input, returning a string containing the data up to and including the delimiter. If ReadString encounters an error before finding a delimiter, it returns the data read before the error and the error itself (often [io.EOF]). ReadString returns err != nil if and only if the returned data does not end in delim.
func (b *Buffer) ReadString(delim byte) (line string, err error)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 Repeat(b []byte, count int) []byteReplace 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 Replace(s []byte, old []byte, new []byte, n int) []byteReplaceAll 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 ReplaceAll(s []byte, old []byte, new []byte) []byteReset resets the [Reader] to be reading from b.
func (r *Reader) Reset(b []byte)Reset resets the buffer to be empty, but it retains the underlying storage for use by future writes. Reset is the same as [Buffer.Truncate](0).
func (b *Buffer) Reset()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 Runes(s []byte) []runeSeek implements the [io.Seeker] interface.
func (r *Reader) Seek(offset int64, whence int) (int64, error)Size returns the original length of the underlying byte slice. Size is the number of bytes available for reading via [Reader.ReadAt]. The result is unaffected by any method calls except [Reader.Reset].
func (r *Reader) Size() int64Split 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. To split around the first instance of a separator, see [Cut].
func Split(s []byte, sep []byte) [][]byteSplitAfter 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 SplitAfter(s []byte, sep []byte) [][]byteSplitAfterN 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 SplitAfterN(s []byte, sep []byte, n int) [][]byteSplitAfterSeq returns an iterator over subslices of s split after each instance of sep. The iterator yields the same subslices that would be returned by [SplitAfter](s, sep), but without constructing a new slice containing the subslices. It returns a single-use iterator.
func SplitAfterSeq(s []byte, sep []byte) *ast.IndexExprSplitN 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. To split around the first instance of a separator, see [Cut].
func SplitN(s []byte, sep []byte, n int) [][]byteSplitSeq returns an iterator over all subslices of s separated by sep. The iterator yields the same subslices that would be returned by [Split](s, sep), but without constructing a new slice containing the subslices. It returns a single-use iterator.
func SplitSeq(s []byte, sep []byte) *ast.IndexExprString returns the contents of the unread portion of the buffer
as a string. If the [Buffer] is a nil pointer, it returns "
func (b *Buffer) String() stringTitle treats s as UTF-8-encoded bytes and returns a copy with all Unicode letters that begin words mapped to their title case. Deprecated: The rule Title uses for word boundaries does not handle Unicode punctuation properly. Use golang.org/x/text/cases instead.
func Title(s []byte) []byteToLower returns a copy of the byte slice s with all Unicode letters mapped to their lower case.
func ToLower(s []byte) []byteToLowerSpecial 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 ToLowerSpecial(c unicode.SpecialCase, s []byte) []byteToTitle treats s as UTF-8-encoded bytes and returns a copy with all the Unicode letters mapped to their title case.
func ToTitle(s []byte) []byteToTitleSpecial 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 ToTitleSpecial(c unicode.SpecialCase, s []byte) []byteToUpper returns a copy of the byte slice s with all Unicode letters mapped to their upper case.
func ToUpper(s []byte) []byteToUpperSpecial 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 ToUpperSpecial(c unicode.SpecialCase, s []byte) []byteToValidUTF8 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 ToValidUTF8(s []byte, replacement []byte) []byteTrim returns a subslice of s by slicing off all leading and trailing UTF-8-encoded code points contained in cutset.
func Trim(s []byte, cutset string) []byteTrimFunc returns a subslice of s by slicing off all leading and trailing UTF-8-encoded code points c that satisfy f(c).
func TrimFunc(s []byte, f func(r rune) bool) []byteTrimLeft returns a subslice of s by slicing off all leading UTF-8-encoded code points contained in cutset.
func TrimLeft(s []byte, cutset string) []byteTrimLeftFunc 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 TrimLeftFunc(s []byte, f func(r rune) bool) []byteTrimPrefix returns s without the provided leading prefix string. If s doesn't start with prefix, s is returned unchanged.
func TrimPrefix(s []byte, prefix []byte) []byteTrimRight returns a subslice of s by slicing off all trailing UTF-8-encoded code points that are contained in cutset.
func TrimRight(s []byte, cutset string) []byteTrimRightFunc returns a subslice of s by slicing off all trailing UTF-8-encoded code points c that satisfy f(c).
func TrimRightFunc(s []byte, f func(r rune) bool) []byteTrimSpace returns a subslice of s by slicing off all leading and trailing white space, as defined by Unicode.
func TrimSpace(s []byte) []byteTrimSuffix returns s without the provided trailing suffix string. If s doesn't end with suffix, s is returned unchanged.
func TrimSuffix(s []byte, suffix []byte) []byteTruncate discards all but the first n unread bytes from the buffer but continues to use the same allocated storage. It panics if n is negative or greater than the length of the buffer.
func (b *Buffer) Truncate(n int)UnreadByte unreads the last byte returned by the most recent successful read operation that read at least one byte. If a write has happened since the last read, if the last read returned an error, or if the read read zero bytes, UnreadByte returns an error.
func (b *Buffer) UnreadByte() errorUnreadByte complements [Reader.ReadByte] in implementing the [io.ByteScanner] interface.
func (r *Reader) UnreadByte() errorUnreadRune unreads the last rune returned by [Buffer.ReadRune]. If the most recent read or write operation on the buffer was not a successful [Buffer.ReadRune], UnreadRune returns an error. (In this regard it is stricter than [Buffer.UnreadByte], which will unread the last byte from any read operation.)
func (b *Buffer) UnreadRune() errorUnreadRune complements [Reader.ReadRune] in implementing the [io.RuneScanner] interface.
func (r *Reader) UnreadRune() errorWrite appends the contents of p to the buffer, growing the buffer as needed. The return value n is the length of p; err is always nil. If the buffer becomes too large, Write will panic with [ErrTooLarge].
func (b *Buffer) Write(p []byte) (n int, err error)WriteByte appends the byte c to the buffer, growing the buffer as needed. The returned error is always nil, but is included to match [bufio.Writer]'s WriteByte. If the buffer becomes too large, WriteByte will panic with [ErrTooLarge].
func (b *Buffer) WriteByte(c byte) errorWriteRune appends the UTF-8 encoding of Unicode code point r to the buffer, returning its length and an error, which is always nil but is included to match [bufio.Writer]'s WriteRune. The buffer is grown as needed; if it becomes too large, WriteRune will panic with [ErrTooLarge].
func (b *Buffer) WriteRune(r rune) (n int, err error)WriteString appends the contents of s to the buffer, growing the buffer as needed. The return value n is the length of s; err is always nil. If the buffer becomes too large, WriteString will panic with [ErrTooLarge].
func (b *Buffer) WriteString(s string) (n int, err error)WriteTo writes data to w until the buffer is drained or an error occurs. The return value n is the number of bytes written; it always fits into an int, but it is int64 to match the [io.WriterTo] interface. Any error encountered during the write is also returned.
func (b *Buffer) WriteTo(w io.Writer) (n int64, err error)WriteTo implements the [io.WriterTo] interface.
func (r *Reader) WriteTo(w io.Writer) (n int64, err error)contains reports whether c is inside the set.
func (as *asciiSet) contains(c byte) boolcontainsRune is a simplified version of strings.ContainsRune to avoid importing the strings package. We avoid bytes.ContainsRune to avoid allocating a temporary copy of s.
func containsRune(s string, r rune) boolempty reports whether the unread portion of the buffer is empty.
func (b *Buffer) empty() boolexplode splits s into a slice of UTF-8 sequences, one per Unicode code point (still slices of bytes), up to a maximum of n byte slices. Invalid UTF-8 sequences are chopped into individual bytes.
func explode(s []byte, n int) [][]byteexplodeSeq returns an iterator over the runes in s.
func explodeSeq(s []byte) *ast.IndexExprGeneric split: splits after each instance of sep, including sepSave bytes of sep in the subslices.
func genSplit(s []byte, sep []byte, sepSave int, n int) [][]bytegrow grows the buffer to guarantee space for n more bytes. It returns the index where bytes should be written. If the buffer can't grow it will panic with ErrTooLarge.
func (b *Buffer) grow(n int) intgrowSlice grows b by n, preserving the original content of b. If the allocation fails, it panics with ErrTooLarge.
func growSlice(b []byte, n int) []bytefunc indexBytePortable(s []byte, c byte) intindexFunc is the same as IndexFunc except that if truth==false, the sense of the predicate function is inverted.
func indexFunc(s []byte, f func(r rune) bool, truth bool) intisSeparator reports whether the rune could mark a word boundary. TODO: update when package unicode captures more of the properties.
func isSeparator(r rune) boollastIndexFunc is the same as LastIndexFunc except that if truth==false, the sense of the predicate function is inverted.
func lastIndexFunc(s []byte, f func(r rune) bool, truth bool) intmakeASCIISet creates a set of ASCII characters and reports whether all characters in chars are ASCII.
func makeASCIISet(chars string) (as asciiSet, ok bool)readSlice is like ReadBytes but returns a reference to internal buffer data.
func (b *Buffer) readSlice(delim byte) (line []byte, err error)splitSeq is SplitSeq or SplitAfterSeq, configured by how many bytes of sep to include in the results (none or all).
func splitSeq(s []byte, sep []byte, sepSave int) *ast.IndexExprfunc trimLeftASCII(s []byte, as *asciiSet) []bytefunc trimLeftByte(s []byte, c byte) []bytefunc trimLeftUnicode(s []byte, cutset string) []bytefunc trimRightASCII(s []byte, as *asciiSet) []bytefunc trimRightByte(s []byte, c byte) []bytefunc trimRightUnicode(s []byte, cutset string) []bytetryGrowByReslice is an inlineable version of grow for the fast-case where the internal buffer only needs to be resliced. It returns the index where bytes should be written and whether it succeeded.
func (b *Buffer) tryGrowByReslice(n int) (int, bool)Generated with Arrow