23 fix only whitespaces + conditional attributes

This commit is contained in:
Christoph Walther
2023-10-31 21:52:24 +01:00
parent 4e23903b31
commit 027c9e4234
3 changed files with 51 additions and 10 deletions

View File

@@ -1,15 +1,13 @@
package functions
import "unicode"
import "strings"
// check if course is empty or contains only whitespaces
// check if string is empty or contains only whitespaces
func OnlyWhitespace(word string) bool {
for _, letter := range word {
if !unicode.IsSpace(letter) || !(letter == int32(160)) {
return false
}
if len(strings.TrimSpace(word)) == 0 {
return true
}
return true
return false
}
func Contains(s []string, e string) bool {