Files
htwkalender/backend/service/functions/string.go
2023-10-31 21:52:24 +01:00

28 lines
459 B
Go

package functions
import "strings"
// check if string is empty or contains only whitespaces
func OnlyWhitespace(word string) bool {
if len(strings.TrimSpace(word)) == 0 {
return true
}
return false
}
func Contains(s []string, e string) bool {
for _, a := range s {
if a == e {
return true
}
}
return false
}
func ReplaceEmptyString(word string, replacement string) string {
if OnlyWhitespace(word) {
return replacement
}
return word
}