Documentation
¶
Overview ¶
Package strut provides high-level, ergonomic str(ing) ut(lites).
Index ¶
- func FromMutable(seq iter.Seq[Mutable]) iter.Seq[string]
- type Buffer
- func (b *Buffer) Append(buf []byte)
- func (b *Buffer) AppendBool(v bool)
- func (b *Buffer) AppendFloat(f float64, tpl byte, prec, size int)
- func (b *Buffer) AppendInt64(n int64, base int)
- func (b *Buffer) AppendPrint(args ...any) *Buffer
- func (b *Buffer) AppendPrintf(tpl string, args ...any) *Buffer
- func (b *Buffer) AppendPrintln(args ...any) *Buffer
- func (b *Buffer) AppendQuote(str string)
- func (b *Buffer) AppendQuoteASCII(str string)
- func (b *Buffer) AppendQuoteGrapic(str string)
- func (b *Buffer) AppendQuoteRune(r rune)
- func (b *Buffer) AppendQuoteRuneASCII(r rune)
- func (b *Buffer) AppendQuoteRuneGrapic(r rune)
- func (b *Buffer) AppendReplace(s, old, new []byte, n int)
- func (b *Buffer) AppendReplaceAll(s, old, new []byte)
- func (b *Buffer) AppendTrimLeft(str []byte, cut string)
- func (b *Buffer) AppendTrimPrefix(s []byte, prefix []byte)
- func (b *Buffer) AppendTrimRight(str []byte, cut string)
- func (b *Buffer) AppendTrimSpace(str []byte)
- func (b *Buffer) AppendTrimSuffix(s []byte, suffix []byte)
- func (b *Buffer) AppendUint64(n uint64, base int)
- func (b *Buffer) Concat(strs ...string)
- func (b *Buffer) Extend(seq iter.Seq[string])
- func (b *Buffer) ExtendBytes(seq iter.Seq[[]byte])
- func (b *Buffer) ExtendBytesJoin(seq iter.Seq[[]byte], sep []byte)
- func (b *Buffer) ExtendBytesLines(seq iter.Seq[[]byte])
- func (b *Buffer) ExtendJoin(seq iter.Seq[string], sep string)
- func (b *Buffer) ExtendLines(seq iter.Seq[string])
- func (b *Buffer) ExtendMutable(seq iter.Seq[Mutable])
- func (b *Buffer) ExtendMutableJoin(seq iter.Seq[Mutable], sep Mutable)
- func (b *Buffer) ExtendMutableLines(seq iter.Seq[Mutable])
- func (b *Buffer) Format(state fmt.State, _ rune)
- func (b *Buffer) FormatBool(v bool)
- func (b *Buffer) FormatComplex(n complex128, tpl byte, prec, size int)
- func (b *Buffer) FormatFloat(f float64, tpl byte, prec, size int)
- func (b *Buffer) FormatInt64(n int64, base int)
- func (b *Buffer) FormatUint64(n uint64, base int)
- func (b *Buffer) Int(num int)
- func (b *Buffer) Join(s []string, sep string)
- func (b *Buffer) Line()
- func (b *Buffer) Mutable() Mutable
- func (b *Buffer) NLines(n int)
- func (b *Buffer) NTabs(n int)
- func (b *Buffer) Print()
- func (b *Buffer) Println()
- func (b *Buffer) Quote(str string)
- func (b *Buffer) QuoteASCII(str string)
- func (b *Buffer) QuoteGrapic(str string)
- func (b *Buffer) QuoteRune(r rune)
- func (b *Buffer) QuoteRuneASCII(r rune)
- func (b *Buffer) QuoteRuneGrapic(r rune)
- func (b *Buffer) Release()
- func (b *Buffer) Repeat(ln string, n int)
- func (b *Buffer) RepeatByte(char byte, n int)
- func (b *Buffer) RepeatLine(ln string, n int)
- func (b *Buffer) RepeatRune(r rune, n int)
- func (b *Buffer) Tab()
- func (b *Buffer) WhenAppendPrint(cond bool, args ...any) *Buffer
- func (b *Buffer) WhenAppendPrintf(cond bool, tpl string, args ...any) *Buffer
- func (b *Buffer) WhenAppendPrintln(cond bool, args ...any) *Buffer
- func (b *Buffer) WhenConcat(cond bool, strs ...string)
- func (b *Buffer) WhenJoin(cond bool, sl []string, sep string)
- func (b *Buffer) WhenLine(cond bool)
- func (b *Buffer) WhenNLines(cond bool, n int)
- func (b *Buffer) WhenNTabs(cond bool, n int)
- func (b *Buffer) WhenTab(cond bool)
- func (b *Buffer) WhenWrite(cond bool, buf []byte)
- func (b *Buffer) WhenWriteByte(cond bool, bt byte)
- func (b *Buffer) WhenWriteLine(cond bool, ln string)
- func (b *Buffer) WhenWriteLines(cond bool, lns ...string)
- func (b *Buffer) WhenWriteMutable(cond bool, m Mutable)
- func (b *Buffer) WhenWriteMutableLine(cond bool, m Mutable)
- func (b *Buffer) WhenWriteMutableLines(cond bool, ms ...Mutable)
- func (b *Buffer) WhenWriteRune(cond bool, r rune)
- func (b *Buffer) WhenWriteString(cond bool, s string)
- func (b *Buffer) WithReplace(s, old, new string, n int)
- func (b *Buffer) WithReplaceAll(s, old, new string)
- func (b *Buffer) WithTrimLeft(str string, cut string)
- func (b *Buffer) WithTrimPrefix(s string, prefix string)
- func (b *Buffer) WithTrimRight(str string, cut string)
- func (b *Buffer) WithTrimSpace(str string)
- func (b *Buffer) WithTrimSuffix(s string, suffix string)
- func (b *Buffer) WriteBytesLine(ln []byte)
- func (b *Buffer) WriteBytesLines(lns ...[]byte)
- func (b *Buffer) WriteLine(ln string)
- func (b *Buffer) WriteLines(lns ...string)
- func (b *Buffer) WriteMutable(in Mutable)
- func (b *Buffer) WriteMutableLine(in Mutable)
- func (b *Buffer) WriteMutableLines(in ...Mutable)
- type Builder
- func (b *Builder) Append(buf []byte)
- func (b *Builder) AppendBool(v bool)
- func (b *Builder) AppendFloat(f float64, tpl byte, prec, size int)
- func (b *Builder) AppendInt64(n int64, base int)
- func (b *Builder) AppendPrint(args ...any) *Builder
- func (b *Builder) AppendPrintf(tpl string, args ...any) *Builder
- func (b *Builder) AppendPrintln(args ...any) *Builder
- func (b *Builder) AppendQuote(str string)
- func (b *Builder) AppendQuoteASCII(str string)
- func (b *Builder) AppendQuoteGrapic(str string)
- func (b *Builder) AppendQuoteRune(r rune)
- func (b *Builder) AppendQuoteRuneASCII(r rune)
- func (b *Builder) AppendQuoteRuneGrapic(r rune)
- func (b *Builder) AppendReplace(s, old, new []byte, n int)
- func (b *Builder) AppendReplaceAll(s, old, new []byte)
- func (b *Builder) AppendTrimLeft(str []byte, cut string)
- func (b *Builder) AppendTrimPrefix(s []byte, prefix []byte)
- func (b *Builder) AppendTrimRight(str []byte, cut string)
- func (b *Builder) AppendTrimSpace(str []byte)
- func (b *Builder) AppendTrimSuffix(s []byte, suffix []byte)
- func (b *Builder) AppendUint64(n uint64, base int)
- func (b *Builder) Bytes() []byte
- func (b *Builder) Concat(strs ...string)
- func (b *Builder) Extend(seq iter.Seq[string])
- func (b *Builder) ExtendBytes(seq iter.Seq[[]byte])
- func (b *Builder) ExtendBytesJoin(seq iter.Seq[[]byte], sep []byte)
- func (b *Builder) ExtendBytesLines(seq iter.Seq[[]byte])
- func (b *Builder) ExtendJoin(seq iter.Seq[string], sep string)
- func (b *Builder) ExtendLines(seq iter.Seq[string])
- func (b *Builder) ExtendMutable(seq iter.Seq[Mutable])
- func (b *Builder) ExtendMutableJoin(seq iter.Seq[Mutable], sep Mutable)
- func (b *Builder) ExtendMutableLines(seq iter.Seq[Mutable])
- func (b *Builder) Format(state fmt.State, _ rune)
- func (b *Builder) FormatBool(v bool)
- func (b *Builder) FormatComplex(n complex128, tpl byte, prec, size int)
- func (b *Builder) FormatFloat(f float64, tpl byte, prec, size int)
- func (b *Builder) FormatInt64(n int64, base int)
- func (b *Builder) FormatUint64(n uint64, base int)
- func (b *Builder) Int(num int)
- func (b *Builder) Join(s []string, sep string)
- func (b *Builder) Line()
- func (b *Builder) Mutable() Mutable
- func (b *Builder) NLines(n int)
- func (b *Builder) NTabs(n int)
- func (b *Builder) Print()
- func (b *Builder) Println()
- func (b *Builder) Quote(str string)
- func (b *Builder) QuoteASCII(str string)
- func (b *Builder) QuoteGrapic(str string)
- func (b *Builder) QuoteRune(r rune)
- func (b *Builder) QuoteRuneASCII(r rune)
- func (b *Builder) QuoteRuneGrapic(r rune)
- func (b *Builder) Repeat(ln string, n int)
- func (b *Builder) RepeatByte(char byte, n int)
- func (b *Builder) RepeatLine(ln string, n int)
- func (b *Builder) RepeatRune(r rune, n int)
- func (b *Builder) Tab()
- func (b *Builder) WhenAppendPrint(cond bool, args ...any) *Builder
- func (b *Builder) WhenAppendPrintf(cond bool, tpl string, args ...any) *Builder
- func (b *Builder) WhenAppendPrintln(cond bool, args ...any) *Builder
- func (b *Builder) WhenConcat(cond bool, strs ...string)
- func (b *Builder) WhenJoin(cond bool, sl []string, sep string)
- func (b *Builder) WhenLine(cond bool)
- func (b *Builder) WhenNLines(cond bool, n int)
- func (b *Builder) WhenNTabs(cond bool, n int)
- func (b *Builder) WhenTab(cond bool)
- func (b *Builder) WhenWrite(cond bool, buf []byte)
- func (b *Builder) WhenWriteByte(cond bool, bt byte)
- func (b *Builder) WhenWriteLine(cond bool, ln string)
- func (b *Builder) WhenWriteLines(cond bool, lns ...string)
- func (b *Builder) WhenWriteMutable(cond bool, m Mutable)
- func (b *Builder) WhenWriteMutableLine(cond bool, m Mutable)
- func (b *Builder) WhenWriteMutableLines(cond bool, ms ...Mutable)
- func (b *Builder) WhenWriteRune(cond bool, r rune)
- func (b *Builder) WhenWriteString(cond bool, s string)
- func (b *Builder) WithReplace(s, old, new string, n int)
- func (b *Builder) WithReplaceAll(s, old, new string)
- func (b *Builder) WithTrimLeft(str string, cut string)
- func (b *Builder) WithTrimPrefix(s string, prefix string)
- func (b *Builder) WithTrimRight(str string, cut string)
- func (b *Builder) WithTrimSpace(str string)
- func (b *Builder) WithTrimSuffix(s string, suffix string)
- func (b *Builder) WriteBytesLine(ln []byte)
- func (b *Builder) WriteBytesLines(lns ...[]byte)
- func (b *Builder) WriteLine(ln string)
- func (b *Builder) WriteLines(lns ...string)
- func (b *Builder) WriteMutable(in Mutable)
- func (b *Builder) WriteMutableLine(in Mutable)
- func (b *Builder) WriteMutableLines(in ...Mutable)
- type Mutable
- func (mut *Mutable) Append(next *Mutable) *Mutable
- func (mut Mutable) Bytes() []byte
- func (mut Mutable) Cap() int
- func (mut Mutable) Clone() *Mutable
- func (mut Mutable) Compare(b []byte) int
- func (mut Mutable) CompareString(s string) int
- func (mut Mutable) Contains(subslice []byte) bool
- func (mut Mutable) ContainsAny(chars string) bool
- func (mut Mutable) ContainsRune(r rune) bool
- func (mut Mutable) ContainsString(s string) bool
- func (mut Mutable) Copy(dst *Mutable) error
- func (mut Mutable) CopyTo(dst []byte) error
- func (mut Mutable) Count(sep []byte) int
- func (mut Mutable) CountString(sep string) int
- func (mut Mutable) Cut(sep []byte) (before, after []byte, found bool)
- func (mut Mutable) CutPrefix(prefix []byte) (after []byte, found bool)
- func (mut Mutable) CutPrefixString(prefix string) (after []byte, found bool)
- func (mut Mutable) CutString(sep string) (before, after []byte, found bool)
- func (mut Mutable) CutSuffix(suffix []byte) (before []byte, found bool)
- func (mut Mutable) CutSuffixString(suffix string) (before []byte, found bool)
- func (mut Mutable) Equal(b []byte) bool
- func (mut Mutable) EqualFold(s []byte) bool
- func (mut Mutable) EqualFoldString(s string) bool
- func (mut Mutable) EqualString(s string) bool
- func (mut *Mutable) Extend(seq iter.Seq[Mutable]) *Mutable
- func (mut *Mutable) ExtendBytes(seq iter.Seq[[]byte]) *Mutable
- func (mut *Mutable) ExtendBytesJoin(seq iter.Seq[[]byte], sep []byte) *Mutable
- func (mut *Mutable) ExtendJoin(seq iter.Seq[Mutable], sep Mutable) *Mutable
- func (mut *Mutable) ExtendStrings(seq iter.Seq[string]) *Mutable
- func (mut *Mutable) ExtendStringsJoin(seq iter.Seq[string], sep string) *Mutable
- func (mut Mutable) Fields() iter.Seq[Mutable]
- func (mut Mutable) FieldsFunc(f func(rune) bool) iter.Seq[Mutable]
- func (mut Mutable) Format(state fmt.State, _ rune)
- func (mut *Mutable) Grow(n int)
- func (mut Mutable) HasPrefix(prefix []byte) bool
- func (mut Mutable) HasPrefixString(prefix string) bool
- func (mut Mutable) HasSuffix(suffix []byte) bool
- func (mut Mutable) HasSuffixString(suffix string) bool
- func (mut Mutable) Index(sep []byte) int
- func (mut Mutable) IndexAny(chars string) int
- func (mut Mutable) IndexByte(c byte) int
- func (mut Mutable) IndexRune(r rune) int
- func (mut Mutable) IndexString(sep string) int
- func (mut Mutable) IsASCII() bool
- func (mut Mutable) IsNullTerminated() bool
- func (mut Mutable) IsUnicode() bool
- func (mut *Mutable) Join(mutables []Mutable, sep Mutable) *Mutable
- func (mut Mutable) LastIndex(sep []byte) int
- func (mut Mutable) LastIndexAny(chars string) int
- func (mut Mutable) LastIndexByte(c byte) int
- func (mut Mutable) LastIndexString(sep string) int
- func (mut Mutable) Len() int
- func (mut *Mutable) Map(mapping func(rune) rune) *Mutable
- func (mut Mutable) Print()
- func (mut Mutable) Println()
- func (mut Mutable) Reader() io.Reader
- func (mut *Mutable) Release()
- func (mut *Mutable) Repeat(count int) *Mutable
- func (mut *Mutable) Replace(old, new []byte, n int) *Mutable
- func (mut *Mutable) ReplaceAll(old, new []byte) *Mutable
- func (mut *Mutable) ReplaceAllString(old, new string) *Mutable
- func (mut *Mutable) ReplaceString(old, new string, n int) *Mutable
- func (mut *Mutable) Reset()
- func (mut Mutable) Split(sep Mutable) iter.Seq[Mutable]
- func (mut Mutable) SplitAfter(sep Mutable) iter.Seq[Mutable]
- func (mut Mutable) SplitAfterString(sep string) iter.Seq[Mutable]
- func (mut Mutable) SplitString(sep string) iter.Seq[Mutable]
- func (mut Mutable) String() string
- func (mut *Mutable) ToLower() *Mutable
- func (mut *Mutable) ToTitle() *Mutable
- func (mut *Mutable) ToUpper() *Mutable
- func (mut *Mutable) Trim(cutset string) *Mutable
- func (mut *Mutable) TrimFunc(f func(rune) bool) *Mutable
- func (mut *Mutable) TrimLeft(cutset string) *Mutable
- func (mut *Mutable) TrimLeftFunc(f func(rune) bool) *Mutable
- func (mut *Mutable) TrimPrefix(prefix []byte) *Mutable
- func (mut *Mutable) TrimPrefixString(prefix string) *Mutable
- func (mut *Mutable) TrimRight(cutset string) *Mutable
- func (mut *Mutable) TrimRightFunc(f func(rune) bool) *Mutable
- func (mut *Mutable) TrimSpace() *Mutable
- func (mut *Mutable) TrimSuffix(suffix []byte) *Mutable
- func (mut *Mutable) TrimSuffixString(suffix string) *Mutable
- func (mut *Mutable) Write(p []byte) (n int, err error)
- func (mut *Mutable) WriteByte(c byte) error
- func (mut *Mutable) WriteRune(r rune) (n int, err error)
- func (mut *Mutable) WriteString(s string) (n int, err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Buffer ¶
Buffer provides the same interface as Builder but wraps 'bytes.Buffer'.
func BufPrint ¶
BufPrint formats args using default formatting and returns a new Buffer containing the result. Analogous to fmt.Sprint.
func BufPrintf ¶
BufPrintf formats according to tpl and returns a new Buffer containing the result. Analogous to fmt.Sprintf.
func BufPrintln ¶
BufPrintln formats args using default formatting, appends a newline, and returns a new Buffer containing the result. Analogous to fmt.Sprintln.
func MakeBuffer ¶
MakeBuffer retrieves a Buffer from the pool and ensures it has at least the specified capacity. The returned Buffer has zero length. Call Release() when done to return it to the pool for reuse.
func NewBuffer ¶
NewBuffer constructs a new 'strut.Buffer' using the provided 'buf' as the basis of the buffer.
func (*Buffer) Append ¶
Append writes the byte slice 'buf' to the buffer. This is a convenience wrapper around Write.
func (*Buffer) AppendBool ¶
AppendBool writes "true" or "false" according to the value of 'v' to the buffer.
func (*Buffer) AppendFloat ¶
AppendFloat writes the string representation of the floating-point number 'f' to the buffer. The 'tpl' parameter is the format ('b', 'e', 'E', 'f', 'g', 'G', 'x', 'X'), 'prec' controls precision, and 'size' is the number of bits (32 or 64).
func (*Buffer) AppendInt64 ¶
AppendInt64 writes the string representation of 'n' in the given 'base' to the buffer. The 'base' must be between 2 and 36 inclusive.
func (*Buffer) AppendPrint ¶
AppendPrint formats its arguments using default formatting and writes to the buffer. Analogous to fmt.Print, fmt.Fprint, and fmt.Sprint.
func (*Buffer) AppendPrintf ¶
AppendPrintf formats according to a format specifier and writes to the buffer. The 'tpl' parameter is the format string, and 'args' are the values to format. Analgous to fmt.Printf, fmt.Sprintf, and fmt.Fprintf.
func (*Buffer) AppendPrintln ¶
AppendPrintln formats its arguments using default formatting, adds a newline, and writes to the buffer. Analogous to fmt.Println, fmt.Sprintln, fmt.Fprintln.
func (*Buffer) AppendQuote ¶
AppendQuote writes a double-quoted Go string literal representing 'str' to the buffer. The output includes surrounding quotes and uses Go escape sequences.
func (*Buffer) AppendQuoteASCII ¶
AppendQuoteASCII writes a double-quoted Go string literal representing 'str' to the buffer. Non-ASCII characters are escaped using \u or \U sequences.
func (*Buffer) AppendQuoteGrapic ¶
AppendQuoteGrapic writes a double-quoted Go string literal representing 'str' to the buffer. Non-graphic characters as defined by unicode.IsGraphic are escaped.
func (*Buffer) AppendQuoteRune ¶
AppendQuoteRune writes a single-quoted Go character literal representing 'r' to the buffer. The output includes surrounding single quotes and uses Go escape sequences.
func (*Buffer) AppendQuoteRuneASCII ¶
AppendQuoteRuneASCII writes a single-quoted Go character literal representing 'r' to the buffer. Non-ASCII characters are escaped using \u or \U sequences.
func (*Buffer) AppendQuoteRuneGrapic ¶
AppendQuoteRuneGrapic writes a single-quoted Go character literal representing 'r' to the buffer. Non-graphic characters as defined by unicode.IsGraphic are escaped.
func (*Buffer) AppendReplace ¶
AppendReplace writes 's' with the first 'n' non-overlapping instances of 'old' replaced by 'new' to the buffer. If 'n' is negative, all instances are replaced.
func (*Buffer) AppendReplaceAll ¶
AppendReplaceAll writes 's' with all non-overlapping instances of 'old' replaced by 'new' to the buffer.
func (*Buffer) AppendTrimLeft ¶
AppendTrimLeft writes 'str' with all leading characters contained in 'cut' removed to the buffer.
func (*Buffer) AppendTrimPrefix ¶
AppendTrimPrefix writes 's' with the leading 'prefix' string removed to the buffer. If 's' doesn't start with 'prefix', 's' is written unchanged.
func (*Buffer) AppendTrimRight ¶
AppendTrimRight writes 'str' with all trailing characters contained in 'cut' removed to the buffer.
func (*Buffer) AppendTrimSpace ¶
AppendTrimSpace writes 'str' with all leading and trailing whitespace removed to the buffer.
func (*Buffer) AppendTrimSuffix ¶
AppendTrimSuffix writes 's' with the trailing 'suffix' string removed to the buffer. If 's' doesn't end with 'suffix', 's' is written unchanged.
func (*Buffer) AppendUint64 ¶
AppendUint64 writes the string representation of 'n' in the given 'base' to the buffer. The 'base' must be between 2 and 36 inclusive.
func (*Buffer) Concat ¶
Concat writes all provided strings consecutively to the buffer without any separator.
func (*Buffer) Extend ¶
Extend writes all strings from the iterator 'seq' consecutively to the buffer.
func (*Buffer) ExtendBytes ¶
ExtendBytes writes all strings from the iterator 'seq' consecutively to the buffer.
func (*Buffer) ExtendBytesJoin ¶
ExtendBytesJoin writes all strings from the iterator 'seq' to the buffer, separated by 'sep'. The first string is not preceded by a separator.
func (*Buffer) ExtendBytesLines ¶
ExtendBytesLines writes all strings from the iterator 'seq' consecutively to the buffer, interspersing a newline character.
func (*Buffer) ExtendJoin ¶
ExtendJoin writes all strings from the iterator 'seq' to the buffer, separated by 'sep'. The first string is not preceded by a separator.
func (*Buffer) ExtendLines ¶
ExtendLines writes each string from the iterator 'seq' on its own line to the buffer. Each string is followed by a newline character.
func (*Buffer) ExtendMutable ¶
ExtendMutable writes all Mutable byte slices from the iterator 'seq' consecutively to the buffer.
func (*Buffer) ExtendMutableJoin ¶
ExtendMutableJoin writes all Mutable byte slices from the iterator 'seq' to the buffer, separated by 'sep'. The first element is not preceded by a separator.
func (*Buffer) ExtendMutableLines ¶
ExtendMutableLines writes each Mutable byte slice from the iterator 'seq' on its own line to the buffer. Each element is followed by a newline character.
func (*Buffer) Format ¶
Format implements fmt.Formatter, writing the buffer's contents directly to the formatter state without allocating an intermediate string.
func (*Buffer) FormatBool ¶
FormatBool writes "true" or "false" according to the value of 'v' to the buffer.
func (*Buffer) FormatComplex ¶
func (b *Buffer) FormatComplex(n complex128, tpl byte, prec, size int)
FormatComplex writes the string representation of the complex number 'n' to the buffer. The 'tpl' parameter is the format ('b', 'e', 'E', 'f', 'g', 'G', 'x', 'X'), 'prec' controls precision, and 'size' is the total number of bits (64 or 128).
func (*Buffer) FormatFloat ¶
FormatFloat writes the string representation of the floating-point number 'f' to the buffer. The 'tpl' parameter is the format ('b', 'e', 'E', 'f', 'g', 'G', 'x', 'X'), 'prec' controls precision, and 'size' is the number of bits (32 or 64).
func (*Buffer) FormatInt64 ¶
FormatInt64 writes the string representation of 'n' in the given 'base' to the buffer. The 'base' must be between 2 and 36 inclusive.
func (*Buffer) FormatUint64 ¶
FormatUint64 writes the string representation of 'n' in the given 'base' to the buffer. The 'base' must be between 2 and 36 inclusive.
func (*Buffer) Join ¶
Join writes all strings from the slice 's', separated by 'sep', to the buffer. This is analogous to strings.Join but writes directly to the buffer.
func (*Buffer) NLines ¶
NLines writes 'n' newline characters to the buffer. If 'n' is negative, the operaton is a no-op.
func (*Buffer) NTabs ¶
NTabs writes 'n' tabs characters to the buffer. If 'n' is negative, the operaton is a no-op.
func (*Buffer) Print ¶
func (b *Buffer) Print()
Print writes the buffer's contents to standard output.
func (*Buffer) Println ¶
func (b *Buffer) Println()
Println writes the buffer's contents to standard output followed by a newline.
func (*Buffer) Quote ¶
Quote writes a double-quoted Go string literal representing 'str' to the buffer. The output includes surrounding quotes and uses Go escape sequences.
func (*Buffer) QuoteASCII ¶
QuoteASCII writes a double-quoted Go string literal representing 'str' to the buffer. Non-ASCII characters are escaped using \u or \U sequences.
func (*Buffer) QuoteGrapic ¶
QuoteGrapic writes a double-quoted Go string literal representing 'str' to the buffer. Non-graphic characters as defined by unicode.IsGraphic are escaped.
func (*Buffer) QuoteRune ¶
QuoteRune writes a single-quoted Go character literal representing 'r' to the buffer. The output includes surrounding single quotes and uses Go escape sequences.
func (*Buffer) QuoteRuneASCII ¶
QuoteRuneASCII writes a single-quoted Go character literal representing 'r' to the buffer. Non-ASCII characters are escaped using \u or \U sequences.
func (*Buffer) QuoteRuneGrapic ¶
QuoteRuneGrapic writes a single-quoted Go character literal representing 'r' to the buffer. Non-graphic characters as defined by unicode.IsGraphic are escaped.
func (*Buffer) Release ¶
func (b *Buffer) Release()
Release resets the Buffer and returns it to the pool for reuse. Buffers larger than 64KB are not pooled to prevent excessive memory retention. After calling Release, the Buffer should not be used again.
func (*Buffer) Repeat ¶
Repeat writes the string 'ln' to the buffer 'n' times. The 'n' parameter must be non-negative.
func (*Buffer) RepeatByte ¶
RepeatByte writes the byte 'char' to the buffer 'n' times. The 'n' parameter must be non-negative.
func (*Buffer) RepeatLine ¶
RepeatLine writes the string 'ln' followed by a newline to the buffer 'n' times. The 'n' parameter must be non-negative. Each repetition is on its own line.
func (*Buffer) RepeatRune ¶
RepeatRune writes the rune 'r' to the buffer 'n' times. The 'n' parameter must be non-negative.
func (*Buffer) WhenAppendPrint ¶
WhenAppendPrint calls AppendPrint with 'args' if 'cond' is true and is a no-op otherwise.
func (*Buffer) WhenAppendPrintf ¶
WhenAppendPrintf calls AppendPrintf with 'tpl' and 'args' if 'cond' is true and is a no-op otherwise.
func (*Buffer) WhenAppendPrintln ¶
WhenAppendPrintln calls AppendPrintln with 'args' if 'cond' is true and is a no-op otherwise.
func (*Buffer) WhenConcat ¶
WhenConcat concatenates all strings in 'strs' if 'cond' is true and is a no-op otherwise.
func (*Buffer) WhenJoin ¶
WhenJoin joins all strings from 'sl' with 'sep' if 'cond' is true and is a no-op otherwise.
func (*Buffer) WhenNLines ¶
WhenNLines writes 'n' newlines if 'cond' is true and is a no-op otherwise.
func (*Buffer) WhenWrite ¶
WhenWrite writes the byte slice 'buf' if 'cond' is true and is a no-op otherwise.
func (*Buffer) WhenWriteByte ¶
WhenWriteByte writes the byte 'bt' if 'cond' is true and is a no-op otherwise.
func (*Buffer) WhenWriteLine ¶
WhenWriteLine writes the string 'ln' followed by a newline if 'cond' is true and is a no-op otherwise.
func (*Buffer) WhenWriteLines ¶
WhenWriteLines writes each string in 'lns' on its own line if 'cond' is true and is a no-op otherwise.
func (*Buffer) WhenWriteMutable ¶
WhenWriteMutable writes the Mutable byte slice 'm' if 'cond' is true and is a no-op otherwise.
func (*Buffer) WhenWriteMutableLine ¶
WhenWriteMutableLine writes the Mutable byte slice 'm' followed by a newline if 'cond' is true and is a no-op otherwise.
func (*Buffer) WhenWriteMutableLines ¶
WhenWriteMutableLines writes each Mutable byte slice in 'ms' on its own line if 'cond' is true and is a no-op otherwise.
func (*Buffer) WhenWriteRune ¶
WhenWriteRune writes the rune 'r' if 'cond' is true and is a no-op otherwise.
func (*Buffer) WhenWriteString ¶
WhenWriteString writes the string 's' if 'cond' is true and is a no-op otherwise.
func (*Buffer) WithReplace ¶
WithReplace writes 's' with the first 'n' non-overlapping instances of 'old' replaced by 'new' to the buffer. If 'n' is negative, all instances are replaced.
func (*Buffer) WithReplaceAll ¶
WithReplaceAll writes 's' with all non-overlapping instances of 'old' replaced by 'new' to the buffer.
func (*Buffer) WithTrimLeft ¶
WithTrimLeft writes 'str' with all leading characters contained in 'cut' removed to the buffer.
func (*Buffer) WithTrimPrefix ¶
WithTrimPrefix writes 's' with the leading 'prefix' string removed to the buffer. If 's' doesn't start with 'prefix', 's' is written unchanged.
func (*Buffer) WithTrimRight ¶
WithTrimRight writes 'str' with all trailing characters contained in 'cut' removed to the buffer.
func (*Buffer) WithTrimSpace ¶
WithTrimSpace writes 'str' with all leading and trailing whitespace removed to the buffer.
func (*Buffer) WithTrimSuffix ¶
WithTrimSuffix writes 's' with the trailing 'suffix' string removed to the buffer. If 's' doesn't end with 'suffix', 's' is written unchanged.
func (*Buffer) WriteBytesLine ¶
WriteBytesLine writes the string 'ln' followed by a newline character to the buffer.
func (*Buffer) WriteBytesLines ¶
WriteBytesLines writes each string in 'lns' followed by a newline character to the buffer. Each string is written on its own line.
func (*Buffer) WriteLine ¶
WriteLine writes the string 'ln' followed by a newline character to the buffer.
func (*Buffer) WriteLines ¶
WriteLines writes each string in 'lns' followed by a newline character to the buffer. Each string is written on its own line.
func (*Buffer) WriteMutable ¶
WriteMutable writes the Mutable byte slice 'in' to the buffer.
func (*Buffer) WriteMutableLine ¶
WriteMutableLine writes the Mutable byte slice 'in' followed by a newline character to the buffer.
func (*Buffer) WriteMutableLines ¶
WriteMutableLines writes each Mutable byte slice in 'in' followed by a newline character to the buffer. Each element is written on its own line.
type Builder ¶
Builder is a wrapper around strings.Builder, that provides additional higher-level methods for building strings.
func Bprint ¶
Bprint formats args using default formatting and returns a new Builder containing the result. Analogous to fmt.Sprint.
func Bprintf ¶
Bprintf formats according to tpl and returns a new Builder containing the result. Analogous to fmt.Sprintf.
func Bprintln ¶
Bprintln formats args using default formatting, appends a newline, and returns a new Builder containing the result. Analogous to fmt.Sprintln.
func MakeBuilder ¶
MakeBuilder constructs a new Builder with at least the specified capacity preallocated, avoiding early reallocation for known-size outputs.
func (*Builder) Append ¶
Append writes the byte slice 'buf' to the builder. The byte slice is copied during the write operation; the caller retains ownership of 'buf' and may modify it after this call returns. This is a convenience wrapper around Write.
func (*Builder) AppendBool ¶
AppendBool writes "true" or "false" according to the value of 'v' to the builder. This method uses strconv.AppendBool which may be more efficient than FormatBool for avoiding intermediate string allocations in some cases. Functionally equivalent to FormatBool.
func (*Builder) AppendFloat ¶
AppendFloat writes the string representation of the floating-point number 'f' to the builder. The 'tpl' parameter is the format ('b', 'e', 'E', 'f', 'g', 'G', 'x', 'X'), 'prec' controls precision, and 'size' is the number of bits (32 or 64). This method uses strconv.AppendFloat which may be more efficient than FormatFloat for avoiding intermediate string allocations in some cases. Functionally equivalent to FormatFloat.
func (*Builder) AppendInt64 ¶
AppendInt64 writes the string representation of 'n' in the given 'base' to the builder. The 'base' must be between 2 and 36 inclusive. This method uses strconv.AppendInt which may be more efficient than FormatInt64 for avoiding intermediate string allocations in some cases. Functionally equivalent to FormatInt64.
func (*Builder) AppendPrint ¶
AppendPrint formats its arguments using default formatting and writes to the builder. Analogous to fmt.Print, fmt.Fprint, and fmt.Sprint.
func (*Builder) AppendPrintf ¶
AppendPrintf formats according to a format specifier and writes to the builder. The 'tpl' parameter is the format string, and 'args' are the values to format. Analgous to fmt.Printf, fmt.Sprintf, and fmt.Fprintf.
func (*Builder) AppendPrintln ¶
AppendPrintln formats its arguments using default formatting, adds a newline, and writes to the builder. Analogous to fmt.Println, fmt.Sprintln, fmt.Fprintln.
func (*Builder) AppendQuote ¶
AppendQuote writes a double-quoted Go string literal representing 'str' to the builder. The output includes surrounding quotes and uses Go escape sequences. This method uses strconv.AppendQuote which may be more efficient than Quote for avoiding intermediate string allocations in some cases.
func (*Builder) AppendQuoteASCII ¶
AppendQuoteASCII writes a double-quoted Go string literal representing 'str' to the builder. Non-ASCII characters are escaped using \u or \U sequences. This method uses strconv.AppendQuoteToASCII which may be more efficient than QuoteASCII for avoiding intermediate string allocations in some cases.
func (*Builder) AppendQuoteGrapic ¶
AppendQuoteGrapic writes a double-quoted Go string literal representing 'str' to the builder. Non-graphic characters as defined by unicode.IsGraphic are escaped. This method uses strconv.AppendQuoteToGraphic which may be more efficient than QuoteGrapic for avoiding intermediate string allocations in some cases.
func (*Builder) AppendQuoteRune ¶
AppendQuoteRune writes a single-quoted Go character literal representing 'r' to the builder. The output includes surrounding single quotes and uses Go escape sequences. This method uses strconv.AppendQuoteRune which may be more efficient than QuoteRune for avoiding intermediate string allocations in some cases.
func (*Builder) AppendQuoteRuneASCII ¶
AppendQuoteRuneASCII writes a single-quoted Go character literal representing 'r' to the builder. Non-ASCII characters are escaped using \u or \U sequences. This method uses strconv.AppendQuoteRuneToASCII which may be more efficient than QuoteRuneASCII for avoiding intermediate string allocations in some cases.
func (*Builder) AppendQuoteRuneGrapic ¶
AppendQuoteRuneGrapic writes a single-quoted Go character literal representing 'r' to the builder. Non-graphic characters as defined by unicode.IsGraphic are escaped. This method uses strconv.AppendQuoteRuneToGraphic which may be more efficient than QuoteRuneGrapic for avoiding intermediate string allocations in some cases.
func (*Builder) AppendReplace ¶
AppendReplace writes the byte slice 's' with the first 'n' non-overlapping instances of 'old' replaced by 'new' to the builder. If 'n' is negative, all instances are replaced. The input 's' is not modified; a transformed copy is written. This is the byte slice equivalent of WithReplace.
func (*Builder) AppendReplaceAll ¶
AppendReplaceAll writes the byte slice 's' with all non-overlapping instances of 'old' replaced by 'new' to the builder. The input 's' is not modified; a transformed copy is written. This is the byte slice equivalent of WithReplaceAll.
func (*Builder) AppendTrimLeft ¶
AppendTrimLeft writes the byte slice 'str' with all leading characters contained in 'cut' removed to the builder. The input 'str' is not modified; a transformed copy is written. This is the byte slice equivalent of WithTrimLeft.
func (*Builder) AppendTrimPrefix ¶
AppendTrimPrefix writes the byte slice 's' with the leading 'prefix' removed to the builder. If 's' doesn't start with 'prefix', 's' is written unchanged. The input 's' is not modified; a transformed copy is written. This is the byte slice equivalent of WithTrimPrefix.
func (*Builder) AppendTrimRight ¶
AppendTrimRight writes the byte slice 'str' with all trailing characters contained in 'cut' removed to the builder. The input 'str' is not modified; a transformed copy is written. This is the byte slice equivalent of WithTrimRight.
func (*Builder) AppendTrimSpace ¶
AppendTrimSpace writes the byte slice 'str' with all leading and trailing whitespace removed to the builder. The input 'str' is not modified; a transformed copy is written. This is the byte slice equivalent of WithTrimSpace.
func (*Builder) AppendTrimSuffix ¶
AppendTrimSuffix writes the byte slice 's' with the trailing 'suffix' removed to the builder. If 's' doesn't end with 'suffix', 's' is written unchanged. The input 's' is not modified; a transformed copy is written. This is the byte slice equivalent of WithTrimSuffix.
func (*Builder) AppendUint64 ¶
AppendUint64 writes the string representation of 'n' in the given 'base' to the builder. The 'base' must be between 2 and 36 inclusive. This method uses strconv.AppendUint which may be more efficient than FormatUint64 for avoiding intermediate string allocations in some cases. Functionally equivalent to FormatUint64.
func (*Builder) Concat ¶
Concat writes all provided strings consecutively to the builder without any separator.
func (*Builder) Extend ¶
Extend writes all strings from the iterator 'seq' consecutively to the builder.
func (*Builder) ExtendBytes ¶
ExtendBytes writes all byte slices from the iterator 'seq' consecutively to the builder. Each byte slice is copied during the write operation. This is the byte slice equivalent of Extend.
func (*Builder) ExtendBytesJoin ¶
ExtendBytesJoin writes all byte slices from the iterator 'seq' to the builder, separated by 'sep'. The first byte slice is not preceded by a separator. Each byte slice is copied during the write operation. This is the byte slice equivalent of ExtendJoin.
func (*Builder) ExtendBytesLines ¶
ExtendBytesLines writes all byte slices from the iterator 'seq' to the builder, each followed by a newline character. Each byte slice is written on its own line. Each byte slice is copied during the write operation. This is the byte slice equivalent of ExtendLines.
func (*Builder) ExtendJoin ¶
ExtendJoin writes all strings from the iterator 'seq' to the builder, separated by 'sep'. The first string is not preceded by a separator.
func (*Builder) ExtendLines ¶
ExtendLines writes each string from the iterator 'seq' on its own line to the builder. Each string is followed by a newline character.
func (*Builder) ExtendMutable ¶
ExtendMutable writes all Mutable byte slices from the iterator 'seq' consecutively to the builder.
func (*Builder) ExtendMutableJoin ¶
ExtendMutableJoin writes all Mutable byte slices from the iterator 'seq' to the builder, separated by 'sep'. The first element is not preceded by a separator.
func (*Builder) ExtendMutableLines ¶
ExtendMutableLines writes each Mutable byte slice from the iterator 'seq' on its own line to the builder. Each element is followed by a newline character.
func (*Builder) Format ¶
Format implements fmt.Formatter, writing the builder's contents directly to the formatter state without allocating an intermediate string.
func (*Builder) FormatBool ¶
FormatBool writes "true" or "false" according to the value of 'v' to the builder.
func (*Builder) FormatComplex ¶
func (b *Builder) FormatComplex(n complex128, tpl byte, prec, size int)
FormatComplex writes the string representation of the complex number 'n' to the builder. The 'tpl' parameter is the format ('b', 'e', 'E', 'f', 'g', 'G', 'x', 'X'), 'prec' controls precision, and 'size' is the total number of bits (64 or 128).
func (*Builder) FormatFloat ¶
FormatFloat writes the string representation of the floating-point number 'f' to the builder. The 'tpl' parameter is the format ('b', 'e', 'E', 'f', 'g', 'G', 'x', 'X'), 'prec' controls precision, and 'size' is the number of bits (32 or 64).
func (*Builder) FormatInt64 ¶
FormatInt64 writes the string representation of 'n' in the given 'base' to the builder. The 'base' must be between 2 and 36 inclusive.
func (*Builder) FormatUint64 ¶
FormatUint64 writes the string representation of 'n' in the given 'base' to the builder. The 'base' must be between 2 and 36 inclusive.
func (*Builder) Join ¶
Join writes all strings from the slice 's', separated by 'sep', to the builder. This is analogous to strings.Join but writes directly to the builder.
func (*Builder) Line ¶
func (b *Builder) Line()
Line writes a single newline character to the builder.
func (*Builder) NLines ¶
NLines writes 'n' newline characters to the builder. If 'n' is negative, the operaton is a no-op.
func (*Builder) NTabs ¶
NTabs writes 'n' tabs characters to the builder. If 'n' is negative, the operaton is a no-op.
func (*Builder) Print ¶
func (b *Builder) Print()
Print writes the builder's contents to standard output.
func (*Builder) Println ¶
func (b *Builder) Println()
Println writes the builder's contents to standard output followed by a newline.
func (*Builder) Quote ¶
Quote writes a double-quoted Go string literal representing 'str' to the builder. The output includes surrounding quotes and uses Go escape sequences.
func (*Builder) QuoteASCII ¶
QuoteASCII writes a double-quoted Go string literal representing 'str' to the builder. Non-ASCII characters are escaped using \u or \U sequences.
func (*Builder) QuoteGrapic ¶
QuoteGrapic writes a double-quoted Go string literal representing 'str' to the builder. Non-graphic characters as defined by unicode.IsGraphic are escaped.
func (*Builder) QuoteRune ¶
QuoteRune writes a single-quoted Go character literal representing 'r' to the builder. The output includes surrounding single quotes and uses Go escape sequences.
func (*Builder) QuoteRuneASCII ¶
QuoteRuneASCII writes a single-quoted Go character literal representing 'r' to the builder. Non-ASCII characters are escaped using \u or \U sequences.
func (*Builder) QuoteRuneGrapic ¶
QuoteRuneGrapic writes a single-quoted Go character literal representing 'r' to the builder. Non-graphic characters as defined by unicode.IsGraphic are escaped.
func (*Builder) Repeat ¶
Repeat writes the string 'ln' to the builder 'n' times. The 'n' parameter must be non-negative.
func (*Builder) RepeatByte ¶
RepeatByte writes the byte 'char' to the builder 'n' times. The 'n' parameter must be non-negative.
func (*Builder) RepeatLine ¶
RepeatLine writes the string 'ln' followed by a newline to the builder 'n' times. The 'n' parameter must be non-negative. Each repetition is on its own line.
func (*Builder) RepeatRune ¶
RepeatRune writes the rune 'r' to the builder 'n' times. The 'n' parameter must be non-negative.
func (*Builder) WhenAppendPrint ¶
WhenAppendPrint calls AppendPrint with 'args' if 'cond' is true and is a no-op otherwise.
func (*Builder) WhenAppendPrintf ¶
WhenAppendPrintf calls AppendPrintf with 'tpl' and 'args' if 'cond' is true and is a no-op otherwise.
func (*Builder) WhenAppendPrintln ¶
WhenAppendPrintln calls AppendPrintln with 'args' if 'cond' is true and is a no-op otherwise.
func (*Builder) WhenConcat ¶
WhenConcat concatenates all strings in 'strs' if 'cond' is true and is a no-op otherwise.
func (*Builder) WhenJoin ¶
WhenJoin joins all strings from 'sl' with 'sep' if 'cond' is true and is a no-op otherwise.
func (*Builder) WhenNLines ¶
WhenNLines writes 'n' newlines if 'cond' is true and is a no-op otherwise.
func (*Builder) WhenTab ¶
WhenTab writes a tab character if 'cond' is true and is a no-op otherwise.
func (*Builder) WhenWrite ¶
WhenWrite writes the byte slice 'buf' if 'cond' is true and is a no-op otherwise.
func (*Builder) WhenWriteByte ¶
WhenWriteByte writes the byte 'bt' if 'cond' is true and is a no-op otherwise.
func (*Builder) WhenWriteLine ¶
WhenWriteLine writes the string 'ln' followed by a newline if 'cond' is true and is a no-op otherwise.
func (*Builder) WhenWriteLines ¶
WhenWriteLines writes each string in 'lns' on its own line if 'cond' is true and is a no-op otherwise.
func (*Builder) WhenWriteMutable ¶
WhenWriteMutable writes the Mutable byte slice 'm' if 'cond' is true and is a no-op otherwise.
func (*Builder) WhenWriteMutableLine ¶
WhenWriteMutableLine writes the Mutable byte slice 'm' followed by a newline if 'cond' is true and is a no-op otherwise.
func (*Builder) WhenWriteMutableLines ¶
WhenWriteMutableLines writes each Mutable byte slice in 'ms' on its own line if 'cond' is true and is a no-op otherwise.
func (*Builder) WhenWriteRune ¶
WhenWriteRune writes the rune 'r' if 'cond' is true and is a no-op otherwise.
func (*Builder) WhenWriteString ¶
WhenWriteString writes the string 's' if 'cond' is true and is a no-op otherwise.
func (*Builder) WithReplace ¶
WithReplace writes 's' with the first 'n' non-overlapping instances of 'old' replaced by 'new' to the builder. If 'n' is negative, all instances are replaced.
func (*Builder) WithReplaceAll ¶
WithReplaceAll writes 's' with all non-overlapping instances of 'old' replaced by 'new' to the builder.
func (*Builder) WithTrimLeft ¶
WithTrimLeft writes 'str' with all leading characters contained in 'cut' removed to the builder.
func (*Builder) WithTrimPrefix ¶
WithTrimPrefix writes 's' with the leading 'prefix' string removed to the builder. If 's' doesn't start with 'prefix', 's' is written unchanged.
func (*Builder) WithTrimRight ¶
WithTrimRight writes 'str' with all trailing characters contained in 'cut' removed to the builder.
func (*Builder) WithTrimSpace ¶
WithTrimSpace writes 'str' with all leading and trailing whitespace removed to the builder.
func (*Builder) WithTrimSuffix ¶
WithTrimSuffix writes 's' with the trailing 'suffix' string removed to the builder. If 's' doesn't end with 'suffix', 's' is written unchanged.
func (*Builder) WriteBytesLine ¶
WriteBytesLine writes the byte slice 'ln' followed by a newline character to the builder. The byte slice is copied during the write operation.
func (*Builder) WriteBytesLines ¶
WriteBytesLines writes each byte slice in 'lns' followed by a newline character to the builder. Each byte slice is written on its own line. Each byte slice is copied during the write operation.
func (*Builder) WriteLine ¶
WriteLine writes the string 'ln' followed by a newline character to the builder.
func (*Builder) WriteLines ¶
WriteLines writes each string in 'lns' followed by a newline character to the builder. Each string is written on its own line.
func (*Builder) WriteMutable ¶
WriteMutable writes the Mutable byte slice 'in' to the builder.
func (*Builder) WriteMutableLine ¶
WriteMutableLine writes the Mutable byte slice 'in' followed by a newline character to the builder.
func (*Builder) WriteMutableLines ¶
WriteMutableLines writes each Mutable byte slice in 'in' followed by a newline character to the builder. Each element is written on its own line.
type Mutable ¶
type Mutable []byte
Mutable provides a pooled, mutable byte slice type for efficient string manipulation. Methods mirror the bytes package API with zero-allocation optimizations for in-place operations and iterator-based splitting. Pointer receiver methods mutate in place; value receiver methods are read-only. The type implements io.Writer and fmt.Formatter.
While it is safe to create Mutable values using `var name Mutable` and `name := Mutable{}`, the NewMutable() constructor takes advantage of a buffer pool, and buffers can be returned to the pool using Release(). Buffers larger than 64KB are not pooled, following the example of the implementation of the buffers in the stdlib fmt package.
Mutake attempts, when possible to, to provide efficient in-place operations and avoids allocation when possible. Split and Fields methods return iter.Seq iterators for zero-allocation iteration.
func MakeMutable ¶
MakeMutable retrieves a Mutable from the pool and ensures it has at least the specified capacity. The returned Mutable has zero length and at least the specified capacity. Like NewMutable, the returned Mutable should be released with Release() when no longer needed.
func Mprint ¶
Mprint formats using the default formats for its operands and returns the resulting string as a Mutable. Spaces are added between operands when neither is a string. The returned Mutable is obtained from the pool and should be released with Release() when no longer needed.
func Mprintf ¶
Mprintf formats according to a format specifier and returns the resulting string as a Mutable. The returned Mutable is obtained from the pool and should be released with Release() when no longer needed. Preallocates based on format string length plus estimated argument size.
func Mprintln ¶
Mprintln formats using the default formats for its operands and returns the resulting string as a Mutable. Spaces are always added between operands and a newline is appended. The returned Mutable is obtained from the pool and should be released with Release() when no longer needed.
func NewMutable ¶
func NewMutable() *Mutable
NewMutable retrieves a Mutable from the pool. The returned Mutable should be released with Release() when no longer needed to enable reuse. The initial content is empty but may have non-zero capacity.
func (*Mutable) Append ¶
Append appends the contents of 'next' to this mutable string, mutating in place. May allocate if capacity is insufficient. Returns the receiver for method chaining.
func (Mutable) Clone ¶
Clone returns a copy of the mutable string. Allocates a new Mutable with the same content.
func (Mutable) CompareString ¶
CompareString returns an integer comparing the mutable string with 's' lexicographically.
func (Mutable) ContainsAny ¶
ContainsAny reports whether any UTF-8 encoded code points in 'chars' are within the mutable string.
func (Mutable) ContainsRune ¶
ContainsRune reports whether rune 'r' is contained in the mutable string.
func (Mutable) ContainsString ¶
ContainsString reports whether string 's' is within the mutable string.
func (Mutable) Copy ¶
Copy copies the contents of this mutable string to 'dst', resizing 'dst' as needed. This overwrites the content of 'dst', reusing the underlying storage if it has sufficient capacity.
func (Mutable) CopyTo ¶
CopyTo copies the contents of this mutable string to 'dst'. Returns an error if 'dst' is too small to hold the contents.
func (Mutable) Count ¶
Count counts the number of non-overlapping instances of 'sep' in the mutable string.
func (Mutable) CountString ¶
CountString counts the number of non-overlapping instances of 'sep' in the mutable string.
func (Mutable) Cut ¶
Cut slices the mutable string around the first instance of 'sep', returning the text before and after 'sep'.
func (Mutable) CutPrefix ¶
CutPrefix returns the mutable string without the provided leading 'prefix' and reports whether it found the prefix.
func (Mutable) CutPrefixString ¶
CutPrefixString returns the mutable string without the provided leading 'prefix' and reports whether it found the prefix.
func (Mutable) CutString ¶
CutString slices the mutable string around the first instance of 'sep', returning the text before and after 'sep'.
func (Mutable) CutSuffix ¶
CutSuffix returns the mutable string without the provided ending 'suffix' and reports whether it found the suffix.
func (Mutable) CutSuffixString ¶
CutSuffixString returns the mutable string without the provided ending 'suffix' and reports whether it found the suffix.
func (Mutable) Equal ¶
Equal reports whether the mutable string and 'b' are the same length and contain the same bytes.
func (Mutable) EqualFold ¶
EqualFold reports whether the mutable string and 's' are equal under Unicode case-folding.
func (Mutable) EqualFoldString ¶
EqualFoldString reports whether the mutable string and 's' are equal under Unicode case-folding.
func (Mutable) EqualString ¶
EqualString reports whether the mutable string and 's' are the same length and contain the same bytes.
func (*Mutable) Extend ¶
Extend appends all Mutable values from seq to the receiver. May allocate if capacity is insufficient.
func (*Mutable) ExtendBytes ¶
ExtendBytes appends all byte slices from seq to the receiver. May allocate if capacity is insufficient.
func (*Mutable) ExtendBytesJoin ¶
ExtendBytesJoin appends []byte values from seq separated by sep. May allocate if capacity is insufficient.
func (*Mutable) ExtendJoin ¶
ExtendJoin appends Mutable values from seq separated by sep. May allocate if capacity is insufficient.
func (*Mutable) ExtendStrings ¶
ExtendStrings appends all strings from seq to the receiver. May allocate if capacity is insufficient.
func (*Mutable) ExtendStringsJoin ¶
ExtendStringsJoin appends strings from seq separated by sep. May allocate if capacity is insufficient.
func (Mutable) Fields ¶
Fields splits the mutable string around each instance of one or more consecutive white space characters, as defined by unicode.IsSpace, returning an iterator that yields each field. Zero allocation for the iterator itself.
func (Mutable) FieldsFunc ¶
FieldsFunc splits the mutable string at each run of code points 'c' satisfying 'f(c)', returning an iterator. Zero allocation for the iterator itself.
func (Mutable) Format ¶
Format implements fmt.Formatter, allowing Mutable to be used directly in formatted output. Writes the underlying bytes to the formatter's state.
func (*Mutable) Grow ¶
Grow increases the capacity of the mutable string by 'n' bytes. May allocate a new underlying array if additional capacity is needed.
func (Mutable) HasPrefixString ¶
HasPrefixString tests whether the mutable string begins with 'prefix'.
func (Mutable) HasSuffixString ¶
HasSuffixString tests whether the mutable string ends with 'suffix'.
func (Mutable) Index ¶
Index returns the index of the first instance of 'sep' in the mutable string, or -1 if 'sep' is not present.
func (Mutable) IndexAny ¶
IndexAny returns the index of the first instance of any code point from 'chars' in the mutable string.
func (Mutable) IndexByte ¶
IndexByte returns the index of the first instance of 'c' in the mutable string, or -1 if 'c' is not present.
func (Mutable) IndexRune ¶
IndexRune returns the index of the first instance of rune 'r', or -1 if the rune is not present.
func (Mutable) IndexString ¶
IndexString returns the index of the first instance of 'sep' in the mutable string, or -1 if 'sep' is not present.
func (Mutable) IsASCII ¶
IsASCII reports whether all bytes in the mutable string are valid ASCII (values 0-127).
func (Mutable) IsNullTerminated ¶
IsNullTerminated reports whether the mutable string ends with a null byte (0x00), indicating C-style null termination.
func (Mutable) IsUnicode ¶
IsUnicode reports whether the mutable string contains only valid UTF-8 encoded Unicode characters.
func (*Mutable) Join ¶
Join appends all mutables from the slice separated by sep. Delegates to ExtendJoin(slices.Values(mutables), sep).
func (Mutable) LastIndex ¶
LastIndex returns the index of the last instance of 'sep' in the mutable string, or -1 if 'sep' is not present.
func (Mutable) LastIndexAny ¶
LastIndexAny returns the index of the last instance of any code point from 'chars' in the mutable string.
func (Mutable) LastIndexByte ¶
LastIndexByte returns the index of the last instance of 'c' in the mutable string, or -1 if 'c' is not present.
func (Mutable) LastIndexString ¶
LastIndexString returns the index of the last instance of 'sep' in the mutable string, or -1 if 'sep' is not present.
func (*Mutable) Map ¶
Map modifies all characters according to the 'mapping' function, mutating in place. May allocate new storage if character widths change.
func (Mutable) Print ¶
func (mut Mutable) Print()
Print writes the contents of the mutable string to standard output.
func (Mutable) Println ¶
func (mut Mutable) Println()
Println writes the context of the Mutable to standard output, adding a new line at the end.
func (Mutable) Reader ¶
Reader provides access to an io.Reader for reading from the mutable string.) Does not copy the underlying data.
func (*Mutable) Release ¶
func (mut *Mutable) Release()
Release resets the Mutable and returns it to the pool for reuse. Any Mutable instance can be released, whether obtained from NewMutable(), MakeMutable(), or created directly. Buffers larger than 64KB are not returned to the pool to prevent excessive memory retention. After calling Release, the Mutable should not be used again.
func (*Mutable) Repeat ¶
Repeat repeats the mutable string 'count' times, mutating in place. Uses zero-allocation in-place copy when sufficient capacity exists; otherwise allocates new storage for the repeated content.
func (*Mutable) Replace ¶
Replace replaces the first 'n' non-overlapping instances of 'old' with 'new', mutating in place. Uses zero-allocation in-place replacement when sufficient capacity exists and replacement is same-length or smaller; otherwise allocates new storage.
func (*Mutable) ReplaceAll ¶
ReplaceAll replaces all non-overlapping instances of 'old' with 'new', mutating in place. Uses zero-allocation in-place replacement when sufficient capacity exists; otherwise allocates new storage.
func (*Mutable) ReplaceAllString ¶
ReplaceAllString replaces all non-overlapping instances of 'old' with 'new', mutating in place. Uses zero-allocation in-place replacement when sufficient capacity exists; otherwise allocates.
func (*Mutable) ReplaceString ¶
ReplaceString replaces the first 'n' non-overlapping instances of 'old' with 'new', mutating in place. Uses zero-allocation in-place replacement when sufficient capacity exists; otherwise allocates.
func (*Mutable) Reset ¶
func (mut *Mutable) Reset()
Reset resets the mutable string to be empty but retains the underlying storage.
func (Mutable) Split ¶
Split returns an iterator that yields subslices separated by 'sep'. Zero allocation for the iterator itself; each yielded slice is a subslice of the original data (no copying).
func (Mutable) SplitAfter ¶
SplitAfter returns an iterator that yields subslices after each instance of 'sep'. Each yielded slice includes the separator. Zero allocation for the iterator itself.
func (Mutable) SplitAfterString ¶
SplitAfterString returns an iterator that yields subslices after each instance of 'sep'. Each yielded slice includes the separator. Zero allocation for the iterator itself.
func (Mutable) SplitString ¶
SplitString returns an iterator that yields subslices separated by 'sep'. Zero allocation for the iterator itself; each yielded slice is a subslice of the original data (no copying).
func (Mutable) String ¶
String returns the mutable string as a regular string. Allocates and copies the underlying bytes.
func (*Mutable) ToLower ¶
ToLower converts all Unicode letters to their lower case, mutating in place. Uses zero-allocation ASCII fast path when possible; only allocates new storage for non-ASCII Unicode content.
func (*Mutable) ToTitle ¶
ToTitle converts all Unicode letters to their title case, mutating in place. Uses zero-allocation ASCII fast path when possible; only allocates new storage for non-ASCII Unicode content.
func (*Mutable) ToUpper ¶
ToUpper converts all Unicode letters to their upper case, mutating in place. Uses zero-allocation ASCII fast path when possible; only allocates new storage for non-ASCII Unicode content.
func (*Mutable) Trim ¶
Trim slices off all leading and trailing UTF-8-encoded code points contained in 'cutset', mutating in place. Returns a subslice, no allocation.
func (*Mutable) TrimFunc ¶
TrimFunc slices off all leading and trailing code points 'c' satisfying 'f(c)', mutating in place. Returns a subslice, no allocation.
func (*Mutable) TrimLeft ¶
TrimLeft slices off all leading UTF-8-encoded code points contained in 'cutset', mutating in place. Returns a subslice, no allocation.
func (*Mutable) TrimLeftFunc ¶
TrimLeftFunc slices off all leading code points 'c' satisfying 'f(c)', mutating in place. Returns a subslice, no allocation.
func (*Mutable) TrimPrefix ¶
TrimPrefix removes the provided leading 'prefix', mutating in place. Returns a subslice, no allocation.
func (*Mutable) TrimPrefixString ¶
TrimPrefixString removes the provided leading 'prefix' string, mutating in place. Returns a subslice, no allocation.
func (*Mutable) TrimRight ¶
TrimRight slices off all trailing UTF-8-encoded code points contained in 'cutset', mutating in place. Returns a subslice, no allocation.
func (*Mutable) TrimRightFunc ¶
TrimRightFunc slices off all trailing code points 'c' satisfying 'f(c)', mutating in place. Returns a subslice, no allocation.
func (*Mutable) TrimSpace ¶
TrimSpace slices off all leading and trailing white space, mutating in place. Returns a subslice, no allocation.
func (*Mutable) TrimSuffix ¶
TrimSuffix removes the provided trailing 'suffix', mutating in place. Returns a subslice, no allocation.
func (*Mutable) TrimSuffixString ¶
TrimSuffixString removes the provided trailing 'suffix' string, mutating in place. Returns a subslice, no allocation.
func (*Mutable) Write ¶
Write implements io.Writer, appending the contents of 'p' to the mutable string. May allocate if capacity is insufficient.
func (*Mutable) WriteByte ¶
WriteByte appends a single byte 'c' to the mutable string. May allocate if capacity is insufficient.