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) Bprint(args ...any) *Buffer
- func (b *Buffer) Bprintf(tpl string, args ...any) *Buffer
- func (b *Buffer) Bprintln(args ...any) *Buffer
- 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) 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) PushBool(v bool)
- func (b *Buffer) PushBytes(buf []byte)
- func (b *Buffer) PushComplex(n complex128, tpl byte, prec, size int)
- func (b *Buffer) PushFloat(f float64, tpl byte, prec, size int)
- func (b *Buffer) PushInt(num int)
- func (b *Buffer) PushInt64(n int64, base int)
- func (b *Buffer) PushQuote(str string)
- func (b *Buffer) PushQuoteASCII(str string)
- func (b *Buffer) PushQuoteGrapic(str string)
- func (b *Buffer) PushQuoteRune(r rune)
- func (b *Buffer) PushQuoteRuneASCII(r rune)
- func (b *Buffer) PushQuoteRuneGrapic(r rune)
- func (b *Buffer) PushReplace(s, old, new []byte, n int)
- func (b *Buffer) PushReplaceAll(s, old, new []byte)
- func (b *Buffer) PushString(s string)
- func (b *Buffer) PushTrimLeft(str []byte, cut string)
- func (b *Buffer) PushTrimPrefix(s []byte, prefix []byte)
- func (b *Buffer) PushTrimRight(str []byte, cut string)
- func (b *Buffer) PushTrimSpace(str []byte)
- func (b *Buffer) PushTrimSuffix(s []byte, suffix []byte)
- func (b *Buffer) PushUint64(n uint64, base int)
- 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) WhenBprint(cond bool, args ...any) *Buffer
- func (b *Buffer) WhenBprintf(cond bool, tpl string, args ...any) *Buffer
- func (b *Buffer) WhenBprintln(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) Bprint(args ...any) *Builder
- func (b *Builder) Bprintf(tpl string, args ...any) *Builder
- func (b *Builder) Bprintln(args ...any) *Builder
- 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) 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) PushBool(v bool)
- func (b *Builder) PushBytes(buf []byte)
- func (b *Builder) PushComplex(n complex128, tpl byte, prec, size int)
- func (b *Builder) PushFloat(f float64, tpl byte, prec, size int)
- func (b *Builder) PushInt(num int)
- func (b *Builder) PushInt64(n int64, base int)
- func (b *Builder) PushQuote(str string)
- func (b *Builder) PushQuoteASCII(str string)
- func (b *Builder) PushQuoteGrapic(str string)
- func (b *Builder) PushQuoteRune(r rune)
- func (b *Builder) PushQuoteRuneASCII(r rune)
- func (b *Builder) PushQuoteRuneGrapic(r rune)
- func (b *Builder) PushReplace(s, old, new []byte, n int)
- func (b *Builder) PushReplaceAll(s, old, new []byte)
- func (b *Builder) PushString(s string)
- func (b *Builder) PushTrimLeft(str []byte, cut string)
- func (b *Builder) PushTrimPrefix(s []byte, prefix []byte)
- func (b *Builder) PushTrimRight(str []byte, cut string)
- func (b *Builder) PushTrimSpace(str []byte)
- func (b *Builder) PushTrimSuffix(s []byte, suffix []byte)
- func (b *Builder) PushUint64(n uint64, base int)
- 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) WhenBprint(cond bool, args ...any) *Builder
- func (b *Builder) WhenBprintf(cond bool, tpl string, args ...any) *Builder
- func (b *Builder) WhenBprintln(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) 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) Concat(strs ...string)
- 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) ExtendBytesLines(seq iter.Seq[[]byte])
- func (mut *Mutable) ExtendJoin(seq iter.Seq[Mutable], sep Mutable) *Mutable
- func (mut *Mutable) ExtendLines(seq iter.Seq[Mutable])
- func (mut *Mutable) ExtendStrings(seq iter.Seq[string]) *Mutable
- func (mut *Mutable) ExtendStringsJoin(seq iter.Seq[string], sep string) *Mutable
- func (mut *Mutable) ExtendStringsLines(seq iter.Seq[string])
- 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) JoinStrings(s []string, sep string)
- 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) Line()
- func (mut *Mutable) Map(mapping func(rune) rune) *Mutable
- func (mut *Mutable) Mprint(args ...any) *Mutable
- func (mut *Mutable) Mprintf(tpl string, args ...any) *Mutable
- func (mut *Mutable) Mprintln(args ...any) *Mutable
- func (mut *Mutable) NLines(n int)
- func (mut *Mutable) NTabs(n int)
- func (mut Mutable) Print()
- func (mut Mutable) Println()
- func (mut *Mutable) Push(next *Mutable) *Mutable
- func (mut *Mutable) PushBool(v bool)
- func (mut *Mutable) PushBytes(p []byte)
- func (mut *Mutable) PushComplex(n complex128, tpl byte, prec, size int)
- func (mut *Mutable) PushFloat(f float64, tpl byte, prec, size int)
- func (mut *Mutable) PushInt(num int)
- func (mut *Mutable) PushInt64(n int64, base int)
- func (mut *Mutable) PushQuote(str string)
- func (mut *Mutable) PushQuoteASCII(str string)
- func (mut *Mutable) PushQuoteGrapic(str string)
- func (mut *Mutable) PushQuoteRune(r rune)
- func (mut *Mutable) PushQuoteRuneASCII(r rune)
- func (mut *Mutable) PushQuoteRuneGrapic(r rune)
- func (mut *Mutable) PushReplace(s, old, new []byte, n int)
- func (mut *Mutable) PushReplaceAll(s, old, new []byte)
- func (mut *Mutable) PushString(s string)
- func (mut *Mutable) PushTrimLeft(str []byte, cut string)
- func (mut *Mutable) PushTrimPrefix(s, prefix []byte)
- func (mut *Mutable) PushTrimRight(str []byte, cut string)
- func (mut *Mutable) PushTrimSpace(str []byte)
- func (mut *Mutable) PushTrimSuffix(s, suffix []byte)
- func (mut *Mutable) PushUint64(n uint64, base int)
- func (mut Mutable) Reader() io.Reader
- func (mut *Mutable) Release()
- func (mut *Mutable) Repeat(count int) *Mutable
- func (mut *Mutable) RepeatByte(char byte, n int)
- func (mut *Mutable) RepeatLine(ln string, n int)
- func (mut *Mutable) RepeatRune(r rune, n int)
- 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) Tab()
- 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) WhenConcat(cond bool, strs ...string)
- func (mut *Mutable) WhenJoin(cond bool, sl []string, sep string)
- func (mut *Mutable) WhenLine(cond bool)
- func (mut *Mutable) WhenMprint(cond bool, args ...any) *Mutable
- func (mut *Mutable) WhenMprintf(cond bool, tpl string, args ...any) *Mutable
- func (mut *Mutable) WhenMprintln(cond bool, args ...any) *Mutable
- func (mut *Mutable) WhenNLines(cond bool, n int)
- func (mut *Mutable) WhenNTabs(cond bool, n int)
- func (mut *Mutable) WhenTab(cond bool)
- func (mut *Mutable) WhenWrite(cond bool, buf []byte)
- func (mut *Mutable) WhenWriteByte(cond bool, bt byte)
- func (mut *Mutable) WhenWriteLine(cond bool, ln string)
- func (mut *Mutable) WhenWriteLines(cond bool, lns ...string)
- func (mut *Mutable) WhenWriteMutable(cond bool, m Mutable)
- func (mut *Mutable) WhenWriteMutableLine(cond bool, m Mutable)
- func (mut *Mutable) WhenWriteMutableLines(cond bool, ms ...Mutable)
- func (mut *Mutable) WhenWriteRune(cond bool, r rune)
- func (mut *Mutable) WhenWriteString(cond bool, s string)
- func (mut *Mutable) WithReplace(s, old, new string, n int)
- func (mut *Mutable) WithReplaceAll(s, old, new string)
- func (mut *Mutable) WithTrimLeft(str, cut string)
- func (mut *Mutable) WithTrimPrefix(s, prefix string)
- func (mut *Mutable) WithTrimRight(str, cut string)
- func (mut *Mutable) WithTrimSpace(str string)
- func (mut *Mutable) WithTrimSuffix(s, suffix string)
- func (mut *Mutable) Write(p []byte) (n int, err error)
- func (mut *Mutable) WriteByte(c byte) error
- func (mut *Mutable) WriteBytesLine(ln []byte)
- func (mut *Mutable) WriteBytesLines(lns ...[]byte)
- func (mut *Mutable) WriteLine(ln string)
- func (mut *Mutable) WriteLines(lns ...string)
- func (mut *Mutable) WriteMutable(m Mutable)
- func (mut *Mutable) WriteMutableLine(m Mutable)
- func (mut *Mutable) WriteMutableLines(ms ...Mutable)
- 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) Bprint ¶ added in v0.14.8
Bprint formats its arguments using default formatting and writes to the buffer. Analogous to fmt.Print, fmt.Fprint, and fmt.Sprint.
func (*Buffer) Bprintf ¶ added in v0.14.8
Bprintf 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) Bprintln ¶ added in v0.14.8
Bprintln formats its arguments using default formatting, adds a newline, and writes to the buffer. Analogous to fmt.Println, fmt.Sprintln, fmt.Fprintln.
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) 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) PushBool ¶ added in v0.14.8
PushBool writes "true" or "false" according to the value of 'v' to the buffer. PushInt writes the decimal string representation of 'num' to the buffer.
func (*Buffer) PushBytes ¶ added in v0.14.8
PushBytes writes the byte slice 'buf' to the buffer. This is a convenience wrapper around Write.
func (*Buffer) PushComplex ¶ added in v0.14.8
func (b *Buffer) PushComplex(n complex128, tpl byte, prec, size int)
PushComplex 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) PushFloat ¶ added in v0.14.8
PushFloat 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) PushInt ¶ added in v0.14.8
PushInt writes the string representation of the integer 'num' to the buffer.
func (*Buffer) PushInt64 ¶ added in v0.14.8
PushInt64 writes the string representation of 'n' in the given 'base' to the buffer. The 'base' must be between 2 and 36 inclusive.
func (*Buffer) PushQuote ¶ added in v0.14.8
PushQuote writes a double-quoted Go string literal representing 'str' to the buffer. The output includes surrounding quotes and uses Go escape sequences.
func (*Buffer) PushQuoteASCII ¶ added in v0.14.8
PushQuoteASCII writes a double-quoted Go string literal representing 'str' to the buffer. Non-ASCII characters are escaped using \u or \U sequences.
func (*Buffer) PushQuoteGrapic ¶ added in v0.14.8
PushQuoteGrapic writes a double-quoted Go string literal representing 'str' to the buffer. Non-graphic characters as defined by unicode.IsGraphic are escaped.
func (*Buffer) PushQuoteRune ¶ added in v0.14.8
PushQuoteRune 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) PushQuoteRuneASCII ¶ added in v0.14.8
PushQuoteRuneASCII writes a single-quoted Go character literal representing 'r' to the buffer. Non-ASCII characters are escaped using \u or \U sequences.
func (*Buffer) PushQuoteRuneGrapic ¶ added in v0.14.8
PushQuoteRuneGrapic writes a single-quoted Go character literal representing 'r' to the buffer. Non-graphic characters as defined by unicode.IsGraphic are escaped.
func (*Buffer) PushReplace ¶ added in v0.14.8
PushReplace 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) PushReplaceAll ¶ added in v0.14.8
PushReplaceAll writes 's' with all non-overlapping instances of 'old' replaced by 'new' to the buffer.
func (*Buffer) PushString ¶ added in v0.14.8
PushString appends string 's' to the buffer.
func (*Buffer) PushTrimLeft ¶ added in v0.14.8
PushTrimLeft writes 'str' with all leading characters contained in 'cut' removed to the buffer.
func (*Buffer) PushTrimPrefix ¶ added in v0.14.8
PushTrimPrefix writes 's' with the leading 'prefix' string removed to the buffer. If 's' doesn't start with 'prefix', 's' is written unchanged.
func (*Buffer) PushTrimRight ¶ added in v0.14.8
PushTrimRight writes 'str' with all trailing characters contained in 'cut' removed to the buffer.
func (*Buffer) PushTrimSpace ¶ added in v0.14.8
PushTrimSpace writes 'str' with all leading and trailing whitespace removed to the buffer.
func (*Buffer) PushTrimSuffix ¶ added in v0.14.8
PushTrimSuffix writes 's' with the trailing 'suffix' string removed to the buffer. If 's' doesn't end with 'suffix', 's' is written unchanged.
func (*Buffer) PushUint64 ¶ added in v0.14.8
PushUint64 writes the string representation of 'n' in the given 'base' to the buffer. The 'base' must be between 2 and 36 inclusive.
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) WhenBprint ¶ added in v0.14.8
WhenBprint calls Bprint with 'args' if 'cond' is true and is a no-op otherwise.
func (*Buffer) WhenBprintf ¶ added in v0.14.8
WhenBprintf calls Bprintf with 'tpl' and 'args' if 'cond' is true and is a no-op otherwise.
func (*Buffer) WhenBprintln ¶ added in v0.14.8
WhenBprintln calls Bprintln 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) Bprint ¶ added in v0.14.8
Bprint formats its arguments using default formatting and writes to the builder. Analogous to fmt.Print, fmt.Fprint, and fmt.Sprint.
func (*Builder) Bprintf ¶ added in v0.14.8
Bprintf 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) Bprintln ¶ added in v0.14.8
Bprintln formats its arguments using default formatting, adds a newline, and writes to the builder. Analogous to fmt.Println, fmt.Sprintln, fmt.Fprintln.
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) 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) PushBool ¶ added in v0.14.8
PushBool writes "true" or "false" according to the value of 'v' to the builder. PushInt writes the decimal string representation of 'num' to the builder.
func (*Builder) PushBytes ¶ added in v0.14.8
PushBytes 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) PushComplex ¶ added in v0.14.8
func (b *Builder) PushComplex(n complex128, tpl byte, prec, size int)
PushComplex 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) PushFloat ¶ added in v0.14.8
PushFloat 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) PushInt ¶ added in v0.14.8
PushInt writes the string representation of the integer 'num' to the builder.
func (*Builder) PushInt64 ¶ added in v0.14.8
PushInt64 writes the string representation of 'n' in the given 'base' to the builder. The 'base' must be between 2 and 36 inclusive.
func (*Builder) PushQuote ¶ added in v0.14.8
PushQuote writes a double-quoted Go string literal representing 'str' to the builder. The output includes surrounding quotes and uses Go escape sequences.
func (*Builder) PushQuoteASCII ¶ added in v0.14.8
PushQuoteASCII writes a double-quoted Go string literal representing 'str' to the builder. Non-ASCII characters are escaped using \u or \U sequences.
func (*Builder) PushQuoteGrapic ¶ added in v0.14.8
PushQuoteGrapic writes a double-quoted Go string literal representing 'str' to the builder. Non-graphic characters as defined by unicode.IsGraphic are escaped.
func (*Builder) PushQuoteRune ¶ added in v0.14.8
PushQuoteRune 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) PushQuoteRuneASCII ¶ added in v0.14.8
PushQuoteRuneASCII writes a single-quoted Go character literal representing 'r' to the builder. Non-ASCII characters are escaped using \u or \U sequences.
func (*Builder) PushQuoteRuneGrapic ¶ added in v0.14.8
PushQuoteRuneGrapic writes a single-quoted Go character literal representing 'r' to the builder. Non-graphic characters as defined by unicode.IsGraphic are escaped.
func (*Builder) PushReplace ¶ added in v0.14.8
PushReplace 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) PushReplaceAll ¶ added in v0.14.8
PushReplaceAll 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) PushString ¶ added in v0.14.8
PushString appends string 's' to the builder.
func (*Builder) PushTrimLeft ¶ added in v0.14.8
PushTrimLeft 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) PushTrimPrefix ¶ added in v0.14.8
PushTrimPrefix 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) PushTrimRight ¶ added in v0.14.8
PushTrimRight 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) PushTrimSpace ¶ added in v0.14.8
PushTrimSpace 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) PushTrimSuffix ¶ added in v0.14.8
PushTrimSuffix 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) PushUint64 ¶ added in v0.14.8
PushUint64 writes the string representation of 'n' in the given 'base' to the builder. The 'base' must be between 2 and 36 inclusive.
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) WhenBprint ¶ added in v0.14.8
WhenBprint calls Bprint with 'args' if 'cond' is true and is a no-op otherwise.
func (*Builder) WhenBprintf ¶ added in v0.14.8
WhenBprintf calls Bprintf with 'tpl' and 'args' if 'cond' is true and is a no-op otherwise.
func (*Builder) WhenBprintln ¶ added in v0.14.8
WhenBprintln calls Bprintln 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) 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) Concat ¶ added in v0.14.8
Concat writes all strings in strs consecutively to the mutable.
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) ExtendBytesLines ¶ added in v0.14.8
ExtendBytesLines writes each byte slice from seq on its own line to the mutable.
func (*Mutable) ExtendJoin ¶
ExtendJoin appends Mutable values from seq separated by sep. May allocate if capacity is insufficient.
func (*Mutable) ExtendLines ¶ added in v0.14.8
ExtendLines writes each Mutable from seq on its own line to the mutable.
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) ExtendStringsLines ¶ added in v0.14.8
ExtendStringsLines writes each string from seq on its own line to the mutable.
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) JoinStrings ¶ added in v0.14.8
JoinStrings writes all strings from s separated by sep to the mutable.
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) Line ¶ added in v0.14.8
func (mut *Mutable) Line()
Line writes a single newline character to the mutable.
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) Mprint ¶ added in v0.14.8
Mprint formats args using default formatting and writes to the mutable. Analogous to fmt.Fprint.
func (*Mutable) Mprintf ¶ added in v0.14.8
Mprintf formats according to tpl and writes to the mutable. Analogous to fmt.Fprintf.
func (*Mutable) Mprintln ¶ added in v0.14.8
Mprintln formats args using default formatting, appends a newline, and writes to the mutable. Analogous to fmt.Fprintln.
func (*Mutable) NLines ¶ added in v0.14.8
NLines writes n newline characters to the mutable. If n is negative, it is a no-op.
func (*Mutable) NTabs ¶ added in v0.14.8
NTabs writes n tab characters to the mutable. If n is negative, it is a no-op.
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) Push ¶ added in v0.14.8
Push 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) PushBytes ¶ added in v0.14.8
PushBytes appends the byte slice 'p' to the mutable string. May allocate if capacity is insufficient.
func (*Mutable) PushComplex ¶ added in v0.14.8
func (mut *Mutable) PushComplex(n complex128, tpl byte, prec, size int)
PushComplex writes the string representation of n to the mutable. 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 (*Mutable) PushFloat ¶ added in v0.14.8
PushFloat writes the string representation of f to the mutable. 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 (*Mutable) PushInt ¶ added in v0.14.8
PushInt writes the decimal string representation of num to the mutable.
func (*Mutable) PushInt64 ¶ added in v0.14.8
PushInt64 writes the string representation of n in the given base to the mutable.
func (*Mutable) PushQuote ¶ added in v0.14.8
PushQuote writes a double-quoted Go string literal for str to the mutable.
func (*Mutable) PushQuoteASCII ¶ added in v0.14.8
PushQuoteASCII writes a double-quoted Go string literal for str, escaping non-ASCII.
func (*Mutable) PushQuoteGrapic ¶ added in v0.14.8
PushQuoteGrapic writes a double-quoted Go string literal for str, escaping non-graphic chars.
func (*Mutable) PushQuoteRune ¶ added in v0.14.8
PushQuoteRune writes a single-quoted Go character literal for r to the mutable.
func (*Mutable) PushQuoteRuneASCII ¶ added in v0.14.8
PushQuoteRuneASCII writes a single-quoted Go character literal for r, escaping non-ASCII.
func (*Mutable) PushQuoteRuneGrapic ¶ added in v0.14.8
PushQuoteRuneGrapic writes a single-quoted Go character literal for r, escaping non-graphic chars.
func (*Mutable) PushReplace ¶ added in v0.14.8
PushReplace writes s with the first n non-overlapping instances of old replaced by new. If n is negative, all instances are replaced.
func (*Mutable) PushReplaceAll ¶ added in v0.14.8
PushReplaceAll writes s with all non-overlapping instances of old replaced by new.
func (*Mutable) PushString ¶ added in v0.14.8
PushString appends string 's' to the mutable string. May allocate if capacity is insufficient.
func (*Mutable) PushTrimLeft ¶ added in v0.14.8
PushTrimLeft writes str with leading characters in cut removed. bytes.TrimLeft returns a subslice of str (no allocation).
func (*Mutable) PushTrimPrefix ¶ added in v0.14.8
PushTrimPrefix writes s with the leading prefix removed. bytes.TrimPrefix returns a subslice of s (no allocation).
func (*Mutable) PushTrimRight ¶ added in v0.14.8
PushTrimRight writes str with trailing characters in cut removed. bytes.TrimRight returns a subslice of str (no allocation).
func (*Mutable) PushTrimSpace ¶ added in v0.14.8
PushTrimSpace writes str with all leading and trailing whitespace removed. bytes.TrimSpace returns a subslice of str (no allocation).
func (*Mutable) PushTrimSuffix ¶ added in v0.14.8
PushTrimSuffix writes s with the trailing suffix removed. bytes.TrimSuffix returns a subslice of s (no allocation).
func (*Mutable) PushUint64 ¶ added in v0.14.8
PushUint64 writes the string representation of n in the given base to the mutable.
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) RepeatByte ¶ added in v0.14.8
RepeatByte writes byte 'char' to the mutable 'n' times. If 'n' is non-positive, the operation is a no-op.
func (*Mutable) RepeatLine ¶ added in v0.14.8
RepeatLine writes string 'ln' followed by a newline to the mutable 'n' times. If 'n' is non-positive, the operation is a no-op.
func (*Mutable) RepeatRune ¶ added in v0.14.8
RepeatRune writes rune 'r' to the mutable 'n' times. If 'n' is non-positive, the operation is a no-op.
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) Tab ¶ added in v0.14.8
func (mut *Mutable) Tab()
Tab writes a single tab character to the mutable.
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) WhenConcat ¶ added in v0.14.8
WhenConcat writes all strings in strs consecutively if cond is true.
func (*Mutable) WhenJoin ¶ added in v0.14.8
WhenJoin writes strings from sl joined by sep if cond is true.
func (*Mutable) WhenMprint ¶ added in v0.14.8
WhenMprint calls Mprint with args if cond is true.
func (*Mutable) WhenMprintf ¶ added in v0.14.8
WhenMprintf calls Mprintf with tpl and args if cond is true.
func (*Mutable) WhenMprintln ¶ added in v0.14.8
WhenMprintln calls Mprintln with args if cond is true.
func (*Mutable) WhenNLines ¶ added in v0.14.8
WhenNLines writes n newlines if cond is true.
func (*Mutable) WhenWriteByte ¶ added in v0.14.8
WhenWriteByte writes bt if cond is true.
func (*Mutable) WhenWriteLine ¶ added in v0.14.8
WhenWriteLine writes ln followed by a newline if cond is true.
func (*Mutable) WhenWriteLines ¶ added in v0.14.8
WhenWriteLines writes each string in lns on its own line if cond is true.
func (*Mutable) WhenWriteMutable ¶ added in v0.14.8
WhenWriteMutable writes m if cond is true.
func (*Mutable) WhenWriteMutableLine ¶ added in v0.14.8
WhenWriteMutableLine writes m followed by a newline if cond is true.
func (*Mutable) WhenWriteMutableLines ¶ added in v0.14.8
WhenWriteMutableLines writes each Mutable in ms on its own line if cond is true.
func (*Mutable) WhenWriteRune ¶ added in v0.14.8
WhenWriteRune writes r if cond is true.
func (*Mutable) WhenWriteString ¶ added in v0.14.8
WhenWriteString writes s if cond is true.
func (*Mutable) WithReplace ¶ added in v0.14.8
WithReplace writes s with the first n non-overlapping instances of old replaced by new. If n is negative, all instances are replaced.
func (*Mutable) WithReplaceAll ¶ added in v0.14.8
WithReplaceAll writes s with all non-overlapping instances of old replaced by new.
func (*Mutable) WithTrimLeft ¶ added in v0.14.8
WithTrimLeft writes str with leading characters in cut removed.
func (*Mutable) WithTrimPrefix ¶ added in v0.14.8
WithTrimPrefix writes s with the leading prefix removed.
func (*Mutable) WithTrimRight ¶ added in v0.14.8
WithTrimRight writes str with trailing characters in cut removed.
func (*Mutable) WithTrimSpace ¶ added in v0.14.8
WithTrimSpace writes str with all leading and trailing whitespace removed.
func (*Mutable) WithTrimSuffix ¶ added in v0.14.8
WithTrimSuffix writes s with the trailing suffix removed.
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.
func (*Mutable) WriteBytesLine ¶ added in v0.14.8
WriteBytesLine writes the byte slice ln followed by a newline to the mutable.
func (*Mutable) WriteBytesLines ¶ added in v0.14.8
WriteBytesLines writes each byte slice in lns followed by a newline to the mutable.
func (*Mutable) WriteLine ¶ added in v0.14.8
WriteLine writes string ln followed by a newline to the mutable.
func (*Mutable) WriteLines ¶ added in v0.14.8
WriteLines writes each string in lns followed by a newline to the mutable.
func (*Mutable) WriteMutable ¶ added in v0.14.8
WriteMutable writes the Mutable m to the mutable.
func (*Mutable) WriteMutableLine ¶ added in v0.14.8
WriteMutableLine writes m followed by a newline to the mutable.
func (*Mutable) WriteMutableLines ¶ added in v0.14.8
WriteMutableLines writes each Mutable in ms followed by a newline to the mutable.