iancoleman / strcase

A golang package for converting to snake_case or CamelCase
MIT License
1.01k stars 106 forks source link

ToCamel fails if input is uppercase #39

Open wichert opened 2 years ago

wichert commented 2 years ago

If you run ToCamel("PINEAPPLE") I would expect the output to be "Pineapple". Unexpectedly "PINEAPPLE" is returned. As a workaround you can dostrcase.ToCamel(strings.ToLower(str)), but it would be nice ifToCamel` did the right thing directly.

gummy789j commented 2 years ago

+1

JonasDoe commented 2 years ago

PINEAPPLE could be an acronym. CamelCasing is just not explicit. So there is no "right" thing.

hlindberg commented 11 months ago

Just tested and this works with the now current version. This ticket can be closed.

laknoll commented 11 months ago

This change just broke things for us. The bel package (to generate TypeScript definitions from go types uses ToCamelCase by default for type names. So far this worked nicely for types named e.g. SMSMessage, but those now get converted to Smsmessage which is not quite what we want (and broke the build of our app).

I can probably work around it, but just wanted to note that those kind of hidden behaviour changes in a minor package update can and do have unexpected consequences and side effects. A better solution would have been to add a new function for the new behaviour.