iancoleman / strcase

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

Provides ability to configure custom acronyms #28

Closed tyronewilson closed 3 years ago

tyronewilson commented 3 years ago

I was using strcase to normalise some JSON keys and found that I had an acronym which wasn't being handled nicely. The acronym was "COGS" and it was being used to convert to either Cogs or cOGS. I wanted cogs.

With this PR I can now do

strcase.ConfigureAcronym("COGS", "cogs") 

this now means that using ToLowerCamel("COGS") will give me what I need.

I think this is a useful feature in general as I found that the acronyms were currently limited to "ID": "id" with no way to configure additional ones.

Let me know if you would like to include this :)

tyronewilson commented 3 years ago

Just following up here. Are we able to merge this?

iancoleman commented 3 years ago

Thanks for this and sorry for the delay! Much appreciated and seems like a handy feature.

tyronewilson commented 3 years ago

No worries, glad to help 👍

On Mon, 23 Nov 2020, 01:48 iancoleman, notifications@github.com wrote:

Thanks for this and sorry for the delay! Much appreciated and seems like a handy feature.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/iancoleman/strcase/pull/28#issuecomment-731868062, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAOQI4QI4FF5QWUAKKRTTKTSRGPOFANCNFSM4SUITI7A .