mirror of
https://github.com/duke-git/lancet.git
synced 2026-02-07 06:02:27 +08:00
feat: add UpperFirst func
This commit is contained in:
@@ -54,6 +54,18 @@ func Capitalize(s string) string {
|
||||
return string(out)
|
||||
}
|
||||
|
||||
// UpperFirst converts the first character of string to upper case.
|
||||
func UpperFirst(s string) string {
|
||||
if len(s) == 0 {
|
||||
return ""
|
||||
}
|
||||
|
||||
r, size := utf8.DecodeRuneInString(s)
|
||||
r = unicode.ToUpper(r)
|
||||
|
||||
return string(r) + s[size:]
|
||||
}
|
||||
|
||||
// LowerFirst converts the first character of string to lower case.
|
||||
func LowerFirst(s string) string {
|
||||
if len(s) == 0 {
|
||||
|
||||
Reference in New Issue
Block a user