ToCamelCaseWithDigits function will convert query-arg style strings to CamelCase. We will use `., -, +, :, ;, _, ~, ' ', (, ), {, }, [, ]` as valid delimiters for words. The difference of ToCamelCase that letter after a number becomes capitalized. So, "word.word-word+word:word;word_word~word word(wo
(s string)
| 253 | // So, "word.word-word+word:word;word_word~word word(word)word{word}[word]3word" |
| 254 | // would be converted to WordWordWordWordWordWordWordWordWordWordWordWordWord3Word |
| 255 | func ToCamelCaseWithDigits(s string) string { |
| 256 | res := bytes.NewBuffer(nil) |
| 257 | capNext := true |
| 258 | for _, v := range s { |
| 259 | if unicode.IsUpper(v) { |
| 260 | res.WriteRune(v) |
| 261 | capNext = false |
| 262 | continue |
| 263 | } |
| 264 | if unicode.IsDigit(v) { |
| 265 | res.WriteRune(v) |
| 266 | capNext = true |
| 267 | continue |
| 268 | } |
| 269 | if unicode.IsLower(v) { |
| 270 | if capNext { |
| 271 | res.WriteRune(unicode.ToUpper(v)) |
| 272 | } else { |
| 273 | res.WriteRune(v) |
| 274 | } |
| 275 | capNext = false |
| 276 | continue |
| 277 | } |
| 278 | capNext = true |
| 279 | } |
| 280 | return res.String() |
| 281 | } |
| 282 | |
| 283 | // ToCamelCaseWithInitialisms function will convert query-arg style strings to CamelCase with initialisms in uppercase. |
| 284 | // So, httpOperationId would be converted to HTTPOperationID |