Skip to content

Commit

Permalink
style: unify coding style
Browse files Browse the repository at this point in the history
  • Loading branch information
eiixy committed Jun 18, 2024
1 parent 6d178cd commit 5f102d0
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions string.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,16 +126,20 @@ func CamelCase(str string) string {

// KebabCase converts string to kebab case.
func KebabCase(str string) string {
return strings.Join(Map(Words(str), func(item string, index int) string {
return strings.ToLower(item)
}), "-")
items := Words(str)
for i, item := range items {
items[i] = strings.ToLower(item)
}
return strings.Join(items, "-")
}

// SnakeCase converts string to snake case.
func SnakeCase(str string) string {
return strings.Join(Map(Words(str), func(item string, index int) string {
return strings.ToLower(item)
}), "_")
items := Words(str)
for i, item := range items {
items[i] = strings.ToLower(item)
}
return strings.Join(items, "_")
}

// Words splits string into an array of its words.
Expand Down

0 comments on commit 5f102d0

Please sign in to comment.