Skip to content

Commit

Permalink
feat: add ToKebabCase utility function for string formatting
Browse files Browse the repository at this point in the history
- 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.
  • Loading branch information
tikazyq committed Jan 6, 2025
1 parent 8d8b47e commit c3c629a
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions core/utils/string.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit c3c629a

Please sign in to comment.