Merge pull request #72 from moul/dev/jhayotte/deps

fixes: upgrade huandu/xtrings to handle capital word with func ToCamelCase
This commit is contained in:
Julien Hayotte 2017-09-08 09:52:43 +02:00 committed by GitHub
commit a921a29c7e

View File

@ -44,18 +44,25 @@ func ToCamelCase(str string) string {
return buf.String() return buf.String()
} }
buf.WriteRune(unicode.ToUpper(r0)) r0 = unicode.ToUpper(r0)
r0, size = utf8.DecodeRuneInString(str)
str = str[size:]
for len(str) > 0 { for len(str) > 0 {
r1 = r0 r1 = r0
r0, size = utf8.DecodeRuneInString(str) r0, size = utf8.DecodeRuneInString(str)
str = str[size:] str = str[size:]
if r1 == '_' && r0 != '_' { if r1 == '_' && r0 == '_' {
buf.WriteRune(r1)
continue
}
if r1 == '_' {
r0 = unicode.ToUpper(r0) r0 = unicode.ToUpper(r0)
} else { } else {
r0 = unicode.ToLower(r0)
}
if r1 != '_' {
buf.WriteRune(r1) buf.WriteRune(r1)
} }
} }