2020-05-24 17:34:32 +03:00
|
|
|
package utils
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"strings"
|
|
|
|
)
|
|
|
|
|
|
|
|
func Capitalize(s string) string {
|
|
|
|
return fmt.Sprintf("%s%s", strings.ToUpper(s[:1]), s[1:])
|
|
|
|
}
|
2022-12-01 12:57:07 +03:00
|
|
|
|
|
|
|
func SplitMulti(s string, delimiters ...string) []string {
|
|
|
|
return strings.FieldsFunc(s, func(r rune) bool {
|
|
|
|
for _, d := range delimiters {
|
|
|
|
if string(r) == d {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func FindString(needle string, haystack []string, defaultVal string) string {
|
|
|
|
for _, s := range haystack {
|
|
|
|
if s == needle {
|
|
|
|
return s
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return defaultVal
|
|
|
|
}
|