text

package
v0.0.0-...-5eee607 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package text provides convenience functions for text manipulation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExpandBraceGroups

func ExpandBraceGroups(text string) ([]string, error)

ExpandBraceGroups expands {foo,bar} groups in text by returning every permutation of brace expansions, similar to shell brace expansion.

func FirstNotEmpty

func FirstNotEmpty(choices ...string) string

FirstNotEmpty returns the first string in choices that is not the empty string. If there is no such string, returns the empty string.

func Hash

func Hash(text string) string

Hash returns an opaque hash of text, suitable for use in de-duplication. The hash implementation is unspecified: do not rely on a specific hashing algorithm. Do not assume the returned hash is from a cryptographic hashing function.

func NormalizeSpace

func NormalizeSpace(text string) string

NormalizeSpace normalizes whitespace in text, stripping leading and trailing whitespace and replacing all internal whitespace sequences with a single space " ".

func ParseInt

func ParseInt(text string, defval int) int

ParseInt parses the integer from the text; in case of error, returns the default value.

func RightPadSlice

func RightPadSlice(slice []string, nparts int, pad string) []string

RightPadSlice returns a slice that is at least nparts elements, padding out with new elements equal to `pad`. The original slice may be returned unmodified, or a new slice may be allocated. The original is never modified.

func Str

func Str(any interface{}) string

Str converts any object into a string, either by a direct cast, a call to Stringer.String, falling back to fmt.Sprintf("%s", object). nil converts to "".

Types

This section is empty.

Jump to

Keyboard shortcuts

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