Documentation ¶
Overview ¶
Package stringutil implements string utilities.
Index ¶
- func IsAlpha(r rune) bool
- func IsAlphanumeric(r rune) bool
- func IsLowerAlpha(r rune) bool
- func IsLowerAlphanumeric(r rune) bool
- func IsNumeric(r rune) bool
- func IsUpperAlpha(r rune) bool
- func JoinSliceQuoted(s []string, sep string) string
- func SliceToHumanString(s []string) string
- func SliceToHumanStringOr(s []string) string
- func SliceToHumanStringOrQuoted(s []string) string
- func SliceToHumanStringQuoted(s []string) string
- func SliceToString(s []string) string
- func SliceToUniqueSortedSliceFilterEmptyStrings(s []string) []string
- func SplitTrimLines(output string) []string
- func SplitTrimLinesNoEmpty(output string) []string
- func ToLowerSnakeCase(s string, options ...SnakeCaseOption) string
- func ToPascalCase(s string) string
- func ToUpperSnakeCase(s string, options ...SnakeCaseOption) string
- func TrimLines(output string) string
- func WordWrap(text string, charLimit int) []string
- type SnakeCaseOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsLowerAlphanumeric ¶
IsLowerAlphanumeric returns true for [0-9a-z].
func JoinSliceQuoted ¶
JoinSliceQuoted joins the slice with quotes.
func SliceToHumanString ¶
SliceToHumanString prints the slice as "e1, e2, and e3".
func SliceToHumanStringOr ¶ added in v1.12.0
SliceToHumanStringOr prints the slice as "e1, e2, or e3".
func SliceToHumanStringOrQuoted ¶ added in v1.12.0
SliceToHumanStringOrQuoted prints the slice as `"e1", "e2", or "e3"`.
func SliceToHumanStringQuoted ¶
SliceToHumanStringQuoted prints the slice as `"e1", "e2", and "e3"`.
func SliceToString ¶
SliceToString prints the slice as [e1,e2].
func SliceToUniqueSortedSliceFilterEmptyStrings ¶
SliceToUniqueSortedSliceFilterEmptyStrings returns a sorted copy of s with no duplicates and no empty strings.
Strings with only spaces are considered empty.
func SplitTrimLines ¶
SplitTrimLines splits the output into individual lines and trims the spaces from each line.
func SplitTrimLinesNoEmpty ¶
SplitTrimLinesNoEmpty splits the output into individual lines and trims the spaces from each line.
This removes any empty lines.
func ToLowerSnakeCase ¶
func ToLowerSnakeCase(s string, options ...SnakeCaseOption) string
ToLowerSnakeCase transforms s to lower_snake_case.
func ToPascalCase ¶
ToPascalCase converts s to PascalCase.
Splits on '-', '_', ' ', '\t', '\n', '\r'. Uppercase letters will stay uppercase,
func ToUpperSnakeCase ¶
func ToUpperSnakeCase(s string, options ...SnakeCaseOption) string
ToUpperSnakeCase transforms s to UPPER_SNAKE_CASE.
func TrimLines ¶
TrimLines splits the output into individual lines and trims the spaces from each line.
This also trims the start and end spaces from the original output.
func WordWrap ¶ added in v1.40.0
WordWrap wraps the text by word with a maximum character length per returned line of charLimit.
Adapted from https://github.com/mitchellh/go-wordwrap/blob/ecf0936a077a4bd73a1cc2ac5c370f2b55618d62/wordwrap.go See https://github.com/mitchellh/go-wordwrap/blob/ecf0936a077a4bd73a1cc2ac5c370f2b55618d62/LICENSE.md
Types ¶
type SnakeCaseOption ¶
type SnakeCaseOption func(*snakeCaseOptions)
SnakeCaseOption is an option for snake_case conversions.
func SnakeCaseWithNewWordOnDigits ¶
func SnakeCaseWithNewWordOnDigits() SnakeCaseOption
SnakeCaseWithNewWordOnDigits is a SnakeCaseOption that signifies to split on digits, ie foo_bar_1 instead of foo_bar1.