Skip to content

Commit c3c629a

Browse files
committed
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.
1 parent 8d8b47e commit c3c629a

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

core/utils/string.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,11 @@ func ToPascalCase(s string) string {
2121
s = strings.ReplaceAll(s, " ", "")
2222
return s
2323
}
24+
25+
func ToKebabCase(s string) string {
26+
s = strings.TrimSpace(s)
27+
s = strings.ToLower(s)
28+
s = strings.ReplaceAll(s, " ", "-")
29+
s = strings.ReplaceAll(s, "_", "-")
30+
return s
31+
}

0 commit comments

Comments
 (0)