feat: add ToKebabCase utility function for string formatting

- Introduced a new function ToKebabCase in utils/string.go to convert strings to kebab-case format.
- The function trims whitespace, converts to lowercase, and replaces spaces and underscores with hyphens, enhancing string manipulation capabilities in the codebase.
This commit is contained in:
Marvin Zhang
2025-01-06 22:37:19 +08:00
parent 8d8b47e474
commit c3c629a7d7

View File

@@ -21,3 +21,11 @@ func ToPascalCase(s string) string {
s = strings.ReplaceAll(s, " ", "")
return s
}
func ToKebabCase(s string) string {
s = strings.TrimSpace(s)
s = strings.ToLower(s)
s = strings.ReplaceAll(s, " ", "-")
s = strings.ReplaceAll(s, "_", "-")
return s
}