12345678910111213141516171819202122232425262728293031323334 |
- package util
- import "strings"
- // Title returns a string value with s[0] which has been convert into upper case that
- // there are not empty input text
- func Title(s string) string {
- if len(s) == 0 {
- return s
- }
- return strings.ToUpper(s[:1]) + s[1:]
- }
- // Untitle returns a string value with s[0] which has been convert into lower case that
- // there are not empty input text
- func Untitle(s string) string {
- if len(s) == 0 {
- return s
- }
- return strings.ToLower(s[:1]) + s[1:]
- }
- // Index returns the index where the item equal,it will return -1 if mismatched
- func Index(slice []string, item string) int {
- for i := range slice {
- if slice[i] == item {
- return i
- }
- }
- return -1
- }
|