text

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2022 License: MIT Imports: 1 Imported by: 0

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, seperated 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.

Types

This section is empty.

Jump to

Keyboard shortcuts

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