firstLine returns the first line of s, stripping any trailing newlines.
(s string)
| 323 | |
| 324 | // firstLine returns the first line of s, stripping any trailing newlines. |
| 325 | func firstLine(s string) string { |
| 326 | s = strings.TrimRight(s, "\n") |
| 327 | if before, _, ok := strings.Cut(s, "\n"); ok { |
| 328 | return before |
| 329 | } |
| 330 | return s |
| 331 | } |