Skip to content

go-pkgz/stringutils

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

stringutils Build Status Go Report Card Coverage Status

Package stringutils provides useful string operations.

Details

String manipulation:

  • Contains: checks if slice contains a string.
  • ContainsAnySubstring: checks if string contains any of provided substring.
  • DeDup: removes duplicates from slice of strings, optimized for performance, good for short slices only.
  • DeDupBig: removes duplicates from slice. Should be used instead of DeDup for large slices.
  • SliceToString: converts slice of any to a slice of strings.
  • HasCommonElement: checks if any element of the second slice is in the first slice.
  • HasPrefixSlice: checks if any string in the slice starts with the given prefix.
  • HasSuffixSlice: checks if any string in the slice ends with the given suffix.
  • Truncate: cuts string to the given length and adds ellipsis if it was truncated.
  • TruncateWords: cuts string to the given number of words and adds ellipsis if it was truncated.
  • RandomWord: generates pronounceable random word with given min/max length.

Install and update

go get -u github.com/go-pkgz/stringutils

Usage examples