go-zero/tools/goctl/util/string.go

29 lines
373 B
Go
Raw Normal View History

2020-07-29 17:11:41 +08:00
package util
import "strings"
func Title(s string) string {
if len(s) == 0 {
return s
}
return strings.ToUpper(s[:1]) + s[1:]
}
func Untitle(s string) string {
if len(s) == 0 {
return s
}
return strings.ToLower(s[:1]) + s[1:]
}
func Index(slice []string, item string) int {
for i, _ := range slice {
if slice[i] == item {
return i
}
}
return -1
}