From c73331e20d8ebcf32aad911f3ad9de2a8ebfe435 Mon Sep 17 00:00:00 2001 From: gfanton Date: Tue, 3 Jan 2017 23:41:58 +0100 Subject: [PATCH] Fix camelCase when len = 1 --- helpers.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/helpers.go b/helpers.go index 4eae222..2f3f1aa 100644 --- a/helpers.go +++ b/helpers.go @@ -44,11 +44,18 @@ var ProtoHelpersFuncMap = template.FuncMap{ return strings.ToLower(s[:1]) + s[1:] }, "camelCase": func(s string) string { - return xstrings.ToCamelCase(s) + if len(s) > 1 { + return xstrings.ToCamelCase(s) + } + + return strings.ToUpper(s[:1]) }, "lowerCamelCase": func(s string) string { - cc := xstrings.ToCamelCase(s) - return strings.ToLower(cc[:1]) + cc[1:] + if len(s) > 1 { + s = xstrings.ToCamelCase(s) + } + + return strings.ToLower(s[:1]) + s[1:] }, "snakeCase": func(s string) string { return xstrings.ToSnakeCase(s)