CamelToKebab returns a copy of the string s that is converted from camel case form to '-' separated form.
(s string)
| 345 | |
| 346 | // CamelToKebab returns a copy of the string s that is converted from camel case form to '-' separated form. |
| 347 | func camelToKebab(s string) string { |
| 348 | var output []rune |
| 349 | var segment []rune |
| 350 | for _, r := range s { |
| 351 | if !unicode.IsLower(r) && string(r) != "-" && !unicode.IsNumber(r) { |
| 352 | output = addSegment(output, segment) |
| 353 | segment = nil |
| 354 | } |
| 355 | segment = append(segment, unicode.ToLower(r)) |
| 356 | } |
| 357 | output = addSegment(output, segment) |
| 358 | return string(output) |
| 359 | } |
| 360 | |
| 361 | func addSegment(inrune, segment []rune) []rune { |
| 362 | if len(segment) == 0 { |