From c3c629a7d777235eee3a2dda25ea5417c15f76ef Mon Sep 17 00:00:00 2001 From: Marvin Zhang Date: Mon, 6 Jan 2025 22:37:19 +0800 Subject: [PATCH] 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. --- core/utils/string.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/core/utils/string.go b/core/utils/string.go index b337b114..b2b6c345 100644 --- a/core/utils/string.go +++ b/core/utils/string.go @@ -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 +}