I have a list of strings:
myStrings = []string{
"MyString1",
"SomeName33",
"AaaBbbTutu",
"JaaaKooooTooo"
}
How do I convert them into case snake strings?
mySnakeCaseStrings = []string{
"my_string1",
"some_name33",
"aaa_bbb_tutu",
"jaaa_koooo_tooo"
}
For there's no special function in strings for this. And doing it manually, by custom code, would be a lot of work for such a simple task.
CodePudding user response:
That is what a dedicated library like iancoleman/strcase is for:
It has a function ToSnake(s) which will produce any_kind_of_string from s := "AnyKind of_string".
