mirror of
https://gitlab.dit.htwk-leipzig.de/htwk-software/htwkalender.git
synced 2025-07-25 05:49:13 +02:00
28 lines
459 B
Go
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
|
|
}
|