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