87 string splitting by separator, not whitespace

This commit is contained in:
survellow
2023-12-03 14:41:30 +01:00
parent a991e56115
commit ed99568fb1
7 changed files with 82 additions and 33 deletions

View File

@@ -8,10 +8,19 @@ import (
// check if string is empty or contains only whitespaces
func OnlyWhitespace(word string) bool {
if len(strings.TrimSpace(word)) == 0 {
return true
return len(strings.TrimSpace(word)) == 0
}
// return function to check if rune is a separator
func IsSeparator(separator []rune) func(rune) bool {
return func(character rune) bool {
for _, sep := range separator {
if sep == character {
return true
}
}
return false
}
return false
}
func Contains(s []string, e string) bool {