Documentation ¶
Overview ¶
Package text provides convenience functions for text manipulation.
Index ¶
- func ExpandBraceGroups(text string) ([]string, error)
- func FirstNotEmpty(choices ...string) string
- func Hash(text string) string
- func NormalizeSpace(text string) string
- func ParseInt(text string, defval int) int
- func RightPadSlice(slice []string, nparts int, pad string) []string
- func Str(any interface{}) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExpandBraceGroups ¶
ExpandBraceGroups expands {foo,bar} groups in text by returning every permutation of brace expansions, similar to shell brace expansion.
func FirstNotEmpty ¶
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 ¶
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 ¶
NormalizeSpace normalizes whitespace in text, stripping leading and trailing whitespace and replacing all internal whitespace sequences with a single space " ".
func ParseInt ¶
ParseInt parses the integer from the text; in case of error, returns the default value.
func RightPadSlice ¶
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.
Types ¶
This section is empty.