text

package
v0.0.0-...-c5cf874 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 20, 2024 License: MIT Imports: 2 Imported by: 2

Documentation

Overview

Package text provides functions similar to strings.Join, but based on writers as opposed to strings

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Grow

func Grow(w io.Writer, n int)

Grow calls w.Grow() when w provides a Grow() method

func Join

func Join(writer io.Writer, elems []string, sep string) (n int, err error)

Join writes the elements of elem into writer, separated by sep. Returns the number of runes written and a nil error.

It is like strings.Join, but writes into a writer instead of allocating a strings.Builder.

func Repeat

func Repeat(w io.Writer, s string, count int) (n int, err error)

Repeat writes count instances of s into w. It returns the number of runes written and a nil error. When count would cause an overflow, calls panic().

It is similar to strings.Repeat, but writes into an existing builder without allocating a new one.

When s is empty or count <= 0, no instances of s are written.

func RepeatJoin

func RepeatJoin(w io.Writer, s, sep string, count int) (n int, err error)

RepeatJoin writes s, followed by (count -1) instances of sep + s into w. It returns the number of runes written and a nil error.

When count <= 0, no instances of s or sep are written into count.

func Splitter

func Splitter(chars string) func(string) []string

Splitter returns a function that acts like strings.Split, except that it splits on any rune contained in chars.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL