BytesToLineStrings returns []string lines from []byte input. If addNewLn is true, each string line has a \n appended at end.
(txt []byte, addNewLn bool)
| 16 | // BytesToLineStrings returns []string lines from []byte input. |
| 17 | // If addNewLn is true, each string line has a \n appended at end. |
| 18 | func BytesToLineStrings(txt []byte, addNewLn bool) []string { |
| 19 | lns := bytes.Split(txt, []byte("\n")) |
| 20 | nl := len(lns) |
| 21 | if nl == 0 { |
| 22 | return nil |
| 23 | } |
| 24 | str := make([]string, nl) |
| 25 | for i, l := range lns { |
| 26 | str[i] = string(l) |
| 27 | if addNewLn { |
| 28 | str[i] += "\n" |
| 29 | } |
| 30 | } |
| 31 | return str |
| 32 | } |
| 33 | |
| 34 | // StringLinesToByteLines returns [][]byte lines from []string lines |
| 35 | func StringLinesToByteLines(str []string) [][]byte { |
no test coverage detected