Documentation
¶
Index ¶
- func FilterEmpty(elems []string) []string
- func If(flag bool, trueValue string) string
- func IfElse(flag bool, trueValue, falseValue string) string
- func Indent(prepend, str string) string
- func JoinStringers[T fmt.Stringer](delim string, args ...T) string
- func Lines(s string) []string
- func LinesSeq(s string) iter.Seq[string]
- func MapAndJoin[T any](fn func(T) string, delim string, args ...T) string
- func UnwrapText(input string) string
- func WithSep(a string, separator string, b string) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FilterEmpty ¶
FilterEmpty removes empty strings from the given slice.
func Indent ¶
Indent prepends a string to every line of the given string.
If the string ends in a newline, the resulting string also ends in a newline.
func JoinStringers ¶
JoinStringers concatenates the string representations of the given fmt.Stringer implementations.
func MapAndJoin ¶
MapAndJoin converts each argument to a string using the given function and joins the strings with the given delimiter.
func UnwrapText ¶
UnwrapText reformats wrapped lines by replacing single newlines with spaces, while preserving blank-line paragraph breaks. This allows defining long strings in a readable fashion.
More specifically:
- the input string is broken up into lines;
- each line is trimmed of leading and trailing whitespace;
- leading or trailing empty lines are discarded;
- each run of non-empty lines is joined into a single line, with a space separator;
- resulting single lines are joined with a blank line in-between.
For example: UnwrapText(`
This is a paragraph that is wrapped on multiple lines. This is another paragraph.
`) returns "This is a paragraph that is wrapped on multiple lines.\n\nThis is another paragraph."
Types ¶
This section is empty.