Documentation
¶
Overview ¶
Package stringutils provides utilities for working with strings.
Index ¶
- func Contains(src string, inSlice []string) bool
- func ContainsAnySubstring(s string, subStrings []string) bool
- func DeDup(keys []string) []string
- func DeDupBig(keys []string) (result []string)
- func HasCommonElement(a, b []string) bool
- func HasPrefixSlice(prefix string, slice []string) bool
- func HasSuffixSlice(suffix string, slice []string) bool
- func RandomWord(minLen, maxLen int) string
- func SliceToString(s []any) []string
- func Truncate(s string, maxLen int) string
- func TruncateWords(s string, maxWords int) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContainsAnySubstring ¶
ContainsAnySubstring checks if string contains any of provided substring
func DeDup ¶
DeDup remove duplicates from slice. optimized for performance, good for short slices only!
func DeDupBig ¶
DeDupBig remove duplicates from slice. Should be used instead of DeDup for large slices
func HasCommonElement ¶
HasCommonElement checks if any element of the second slice is in the first slice
func HasPrefixSlice ¶ added in v1.1.0
HasPrefixSlice checks if any string in the slice starts with the given prefix
func HasSuffixSlice ¶ added in v1.1.0
HasSuffixSlice checks if any string in the slice ends with the given suffix
func RandomWord ¶ added in v1.2.0
RandomWord generates pronounceable random word with length between minLen and maxLen
func SliceToString ¶
SliceToString converts slice of any to slice of string
func Truncate ¶ added in v1.2.0
Truncate cuts string to the given length (in runes) and adds ellipsis if it was truncated if maxLen is less than 4 (3 chars for ellipsis + 1 rune from string), returns empty string
func TruncateWords ¶ added in v1.2.0
TruncateWords cuts string to the given number of words and adds ellipsis if it was truncated returns empty string if maxWords is 0
Types ¶
This section is empty.