Merge pull request #38 from gfanton/fix-camelcase
Fix camelCase when len = 1
This commit is contained in:
commit
e8cdc47633
11
helpers.go
11
helpers.go
@ -44,11 +44,18 @@ var ProtoHelpersFuncMap = template.FuncMap{
|
|||||||
return strings.ToLower(s[:1]) + s[1:]
|
return strings.ToLower(s[:1]) + s[1:]
|
||||||
},
|
},
|
||||||
"camelCase": func(s string) string {
|
"camelCase": func(s string) string {
|
||||||
|
if len(s) > 1 {
|
||||||
return xstrings.ToCamelCase(s)
|
return xstrings.ToCamelCase(s)
|
||||||
|
}
|
||||||
|
|
||||||
|
return strings.ToUpper(s[:1])
|
||||||
},
|
},
|
||||||
"lowerCamelCase": func(s string) string {
|
"lowerCamelCase": func(s string) string {
|
||||||
cc := xstrings.ToCamelCase(s)
|
if len(s) > 1 {
|
||||||
return strings.ToLower(cc[:1]) + cc[1:]
|
s = xstrings.ToCamelCase(s)
|
||||||
|
}
|
||||||
|
|
||||||
|
return strings.ToLower(s[:1]) + s[1:]
|
||||||
},
|
},
|
||||||
"snakeCase": func(s string) string {
|
"snakeCase": func(s string) string {
|
||||||
return xstrings.ToSnakeCase(s)
|
return xstrings.ToSnakeCase(s)
|
||||||
|
Loading…
Reference in New Issue
Block a user