feat: add stringx.ToCamelCase (#2622)

This commit is contained in:
Kevin Wan
2022-11-20 17:41:39 +08:00
committed by GitHub
parent 20e659749a
commit 95a5f64493
2 changed files with 65 additions and 0 deletions

View File

@@ -2,6 +2,7 @@ package stringx
import (
"errors"
"unicode"
"github.com/zeromicro/go-zero/core/lang"
)
@@ -168,6 +169,15 @@ func TakeWithPriority(fns ...func() string) string {
return ""
}
// ToCamelCase returns the string that converts the first letter to lowercase.
func ToCamelCase(s string) string {
for i, v := range s {
return string(unicode.ToLower(v)) + s[i+1:]
}
return ""
}
// Union merges the strings in first and second.
func Union(first, second []string) []string {
set := make(map[string]lang.PlaceholderType)