splitEnding separates a line produced by strings.SplitAfter(s, "\n") into its content bytes and its line ending. The ending is one of "\r\n", "\n", or "" (the last slice when the input lacks a trailing newline).
(line string)
| 629 | // one of "\r\n", "\n", or "" (the last slice when the input lacks a |
| 630 | // trailing newline). |
| 631 | func splitEnding(line string) (content, ending string) { |
| 632 | if strings.HasSuffix(line, "\r\n") { |
| 633 | return line[:len(line)-2], "\r\n" |
| 634 | } |
| 635 | if strings.HasSuffix(line, "\n") { |
| 636 | return line[:len(line)-1], "\n" |
| 637 | } |
| 638 | return line, "" |
| 639 | } |
| 640 | |
| 641 | // endingsMatch decides whether two line endings may pair up during |
| 642 | // fuzzy matching. Identical endings always match. "\n" and "\r\n" |
no outgoing calls
no test coverage detected