commit
d4019beef5
8
camel.go
8
camel.go
@ -10,9 +10,13 @@ func toCamelInitCase(s string, initCase bool) string {
|
|||||||
s = strings.Trim(s, " ")
|
s = strings.Trim(s, " ")
|
||||||
n := ""
|
n := ""
|
||||||
capNext := initCase
|
capNext := initCase
|
||||||
for _, v := range s {
|
for i, v := range s {
|
||||||
if v >= 'A' && v <= 'Z' {
|
if v >= 'A' && v <= 'Z' {
|
||||||
n += string(v)
|
if !initCase && i == 0 {
|
||||||
|
n += strings.ToLower(string(v))
|
||||||
|
} else {
|
||||||
|
n += string(v)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if v >= '0' && v <= '9' {
|
if v >= '0' && v <= '9' {
|
||||||
n += string(v)
|
n += string(v)
|
||||||
|
@ -29,6 +29,8 @@ func TestToCamel(t *testing.T) {
|
|||||||
func TestToLowerCamel(t *testing.T) {
|
func TestToLowerCamel(t *testing.T) {
|
||||||
cases := [][]string{
|
cases := [][]string{
|
||||||
[]string{"foo-bar", "fooBar"},
|
[]string{"foo-bar", "fooBar"},
|
||||||
|
[]string{"TestCase", "testCase"},
|
||||||
|
[]string{"AnyKind of_string", "anyKindOfString"},
|
||||||
}
|
}
|
||||||
for _, i := range cases {
|
for _, i := range cases {
|
||||||
in := i[0]
|
in := i[0]
|
||||||
|
Loading…
Reference in New Issue
Block a user