Documentation ¶
Overview ¶
Package stringutil implements string utilities.
Index ¶
- func JoinSliceQuoted(s []string, sep string) string
- func MapToSortedSlice(m map[string]struct{}) []string
- func SliceElementsEqual(one []string, two []string) bool
- func SliceToChunks(s []string, chunkSize int) [][]string
- func SliceToMap(s []string) map[string]struct{}
- func SliceToUniqueSortedSlice(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
- type SnakeCaseOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func JoinSliceQuoted ¶ added in v0.4.1
JoinSliceQuoted joins the slice with quotes.
func MapToSortedSlice ¶
MapToSortedSlice transforms m to a sorted slice.
func SliceElementsEqual ¶ added in v0.4.1
SliceElementsEqual returns true if the two slices have equal elements.
Nil and empty slices are treated as equals.
func SliceToChunks ¶
SliceToChunks splits s into chunks of the given chunk size.
If s is nil or empty, returns empty. If chunkSize is <=0, returns [][]string{s}.
func SliceToUniqueSortedSlice ¶
SliceToUniqueSortedSlice returns a sorted copy of s with no duplicates.
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 ¶ added in v0.15.0
SplitTrimLines splits the output into individual lines and trims the spaces from each line.
func SplitTrimLinesNoEmpty ¶ added in v0.15.0
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.
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.