From 6db729b1365ebbb34cba2285bc113e85f64d2697 Mon Sep 17 00:00:00 2001 From: jhayotte Date: Fri, 8 Sep 2017 09:09:00 +0200 Subject: [PATCH] fix: upgrade huandu/xtrings to handle capital word with func ToCamelCase --- vendor/github.com/huandu/xstrings/convert.go | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/vendor/github.com/huandu/xstrings/convert.go b/vendor/github.com/huandu/xstrings/convert.go index 78ca34d..ecf6fec 100644 --- a/vendor/github.com/huandu/xstrings/convert.go +++ b/vendor/github.com/huandu/xstrings/convert.go @@ -44,18 +44,25 @@ func ToCamelCase(str string) string { return buf.String() } - buf.WriteRune(unicode.ToUpper(r0)) - r0, size = utf8.DecodeRuneInString(str) - str = str[size:] + r0 = unicode.ToUpper(r0) for len(str) > 0 { r1 = r0 r0, size = utf8.DecodeRuneInString(str) str = str[size:] - if r1 == '_' && r0 != '_' { + if r1 == '_' && r0 == '_' { + buf.WriteRune(r1) + continue + } + + if r1 == '_' { r0 = unicode.ToUpper(r0) } else { + r0 = unicode.ToLower(r0) + } + + if r1 != '_' { buf.WriteRune(r1) } }