KebabCase produces the kebab-case version of the given CamelCase string.
(name string)
| 244 | |
| 245 | // KebabCase produces the kebab-case version of the given CamelCase string. |
| 246 | func KebabCase(name string) string { |
| 247 | name = SnakeCase(name) |
| 248 | ln := len(name) |
| 249 | if name[ln-1] == '_' { |
| 250 | name = name[:ln-1] |
| 251 | } |
| 252 | return strings.ReplaceAll(name, "_", "-") |
| 253 | } |
| 254 | |
| 255 | // WrapText produces lines with text capped at maxChars |
| 256 | // it will keep words intact and respects newlines. |