We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 10cd19b commit d646ff2Copy full SHA for d646ff2
1 file changed
app/func.go
@@ -66,3 +66,28 @@ func GetGoId() uint64 {
66
n, _ := strconv.ParseUint(string(b), 10, 64)
67
return n
68
}
69
+
70
+// StringToHump 蛇形转驼峰
71
+func StringToHump(s string) string {
72
+ data := make([]byte, 0, len(s))
73
+ j := false
74
+ k := false
75
+ num := len(s) - 1
76
+ for i := 0; i <= num; i++ {
77
+ d := s[i]
78
+ if k == false && d >= 'A' && d <= 'Z' {
79
+ k = true
80
+ }
81
+ if d >= 'a' && d <= 'z' && (j || k == false) {
82
+ d = d - 32
83
+ j = false
84
85
86
+ if k && (d == '_' || d == '-') && num > i && s[i+1] >= 'a' && s[i+1] <= 'z' {
87
+ j = true
88
+ continue
89
90
+ data = append(data, d)
91
92
+ return string(data[:])
93
+}
0 commit comments