Browse Source

Merge pull request #9 from takuoki/master

Improve ToLowerCamel()
tags/v0.1.0
iancoleman GitHub 6 years ago
parent
commit
90d371a664
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 0 deletions
  1. +6
    -0
      camel.go
  2. +3
    -0
      camel_test.go

+ 6
- 0
camel.go View File

@@ -38,5 +38,11 @@ func ToCamel(s string) string {
}

func ToLowerCamel(s string) string {
if s == "" {
return s
}
if r := rune(s[0]); r >= 'A' && r <= 'Z' {
s = strings.ToLower(string(r)) + s[1:]
}
return toCamelInitCase(s, false)
}

+ 3
- 0
camel_test.go View File

@@ -29,6 +29,9 @@ func TestToCamel(t *testing.T) {
func TestToLowerCamel(t *testing.T) {
cases := [][]string{
[]string{"foo-bar", "fooBar"},
[]string{"TestCase", "testCase"},
[]string{"", ""},
[]string{"AnyKind of_string", "anyKindOfString"},
}
for _, i := range cases {
in := i[0]


Loading…
Cancel
Save